From 0aeea8fe23ab27b0a610b96ed8dbeddc4b6c06d4 Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Wed, 21 Jul 2021 14:56:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9findbugs=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation/ContentProvider.java | 6 ++- .../annotation/TableEndpoint.java | 6 ++- .../com/dbflow5/converter/TypeConverters.java | 7 ++- core/src/main/java/com/dbflow5/data/Blob.java | 16 ++++--- .../main/java/com/dbflow5/sql/SQLiteType.java | 2 +- entry/src/main/java/com/dbflow5/DemoApp.java | 14 ++++++ .../main/java/com/dbflow5/MainAbility.java | 14 ++++++ .../java/com/dbflow5/StubContentProvider.java | 9 ---- .../com/dbflow5/slice/MainAbilitySlice.java | 14 ++++++ .../com/dbflow5/query/cache/ModelCache.java | 2 +- .../java/com/dbflow5/processor/Handlers.java | 29 ++++--------- .../dbflow5/processor/ProcessorManager.java | 22 +++------- .../dbflow5/processor/definition/Methods.java | 10 ++--- .../processor/definition/TableDefinition.java | 28 ++++++------ .../behavior/ComplexColumnBehavior.java | 43 ++++++++++--------- .../processor/utils/ElementUtility.java | 10 +++-- 16 files changed, 129 insertions(+), 103 deletions(-) delete mode 100644 entry/src/main/java/com/dbflow5/StubContentProvider.java diff --git a/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/ContentProvider.java b/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/ContentProvider.java index 2ff3ba05..00e3fd49 100644 --- a/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/ContentProvider.java +++ b/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/ContentProvider.java @@ -5,9 +5,11 @@ package com.dbflow5.contentprovider.annotation; * Description: Defines a Content Provider that gets generated. */ -import java.lang.annotation.*; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; -@Documented @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface ContentProvider{ diff --git a/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/TableEndpoint.java b/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/TableEndpoint.java index b2b8bdc9..e38a0119 100644 --- a/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/TableEndpoint.java +++ b/contentprovider-annotations/src/main/java/com/dbflow5/contentprovider/annotation/TableEndpoint.java @@ -1,11 +1,13 @@ package com.dbflow5.contentprovider.annotation; -import java.lang.annotation.*; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Description: Defines an endpoint that gets placed inside of a [ContentProvider] */ -@Documented @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface TableEndpoint{ diff --git a/core/src/main/java/com/dbflow5/converter/TypeConverters.java b/core/src/main/java/com/dbflow5/converter/TypeConverters.java index 6667a5fe..0d1f5727 100644 --- a/core/src/main/java/com/dbflow5/converter/TypeConverters.java +++ b/core/src/main/java/com/dbflow5/converter/TypeConverters.java @@ -4,7 +4,10 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Time; import java.sql.Timestamp; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.UUID; public class TypeConverters { /** @@ -85,7 +88,7 @@ public class TypeConverters { @Override public Boolean getModelValue(Integer data) { - return null; + return false; } } diff --git a/core/src/main/java/com/dbflow5/data/Blob.java b/core/src/main/java/com/dbflow5/data/Blob.java index c859cf5c..ad998f57 100644 --- a/core/src/main/java/com/dbflow5/data/Blob.java +++ b/core/src/main/java/com/dbflow5/data/Blob.java @@ -4,17 +4,21 @@ package com.dbflow5.data; * Description: Provides a way to support blob format data. */ public final class Blob{ - private byte[] blob; + private final byte[] blob; public Blob(byte[] blob) { - this.blob = blob; + if(blob == null) { + this.blob = null; + }else { + this.blob = blob.clone(); + } } public byte[] getBlob() { - return blob; + if(blob == null) { + return null; + } + return blob.clone(); } - public void setBlob(byte[] blob) { - this.blob = blob; - } } diff --git a/core/src/main/java/com/dbflow5/sql/SQLiteType.java b/core/src/main/java/com/dbflow5/sql/SQLiteType.java index 4ac3e75b..5f09f592 100644 --- a/core/src/main/java/com/dbflow5/sql/SQLiteType.java +++ b/core/src/main/java/com/dbflow5/sql/SQLiteType.java @@ -30,7 +30,7 @@ public enum SQLiteType { */ BLOB; - public static Map sTypeMap = new HashMap<>(); + public static final Map sTypeMap = new HashMap<>(); static { sTypeMap.put(Byte.TYPE.getName(), INTEGER); diff --git a/entry/src/main/java/com/dbflow5/DemoApp.java b/entry/src/main/java/com/dbflow5/DemoApp.java index ed4705ce..67cfc1a1 100644 --- a/entry/src/main/java/com/dbflow5/DemoApp.java +++ b/entry/src/main/java/com/dbflow5/DemoApp.java @@ -1,3 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.dbflow5; import ohos.aafwk.ability.AbilityPackage; diff --git a/entry/src/main/java/com/dbflow5/MainAbility.java b/entry/src/main/java/com/dbflow5/MainAbility.java index 523322b6..29ab985d 100644 --- a/entry/src/main/java/com/dbflow5/MainAbility.java +++ b/entry/src/main/java/com/dbflow5/MainAbility.java @@ -1,3 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.dbflow5; import com.dbflow5.slice.MainAbilitySlice; diff --git a/entry/src/main/java/com/dbflow5/StubContentProvider.java b/entry/src/main/java/com/dbflow5/StubContentProvider.java deleted file mode 100644 index 60e017b9..00000000 --- a/entry/src/main/java/com/dbflow5/StubContentProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dbflow5; - -import ohos.aafwk.ability.DataAbilityHelper; - - -public class StubContentProvider { - - -} \ No newline at end of file diff --git a/entry/src/main/java/com/dbflow5/slice/MainAbilitySlice.java b/entry/src/main/java/com/dbflow5/slice/MainAbilitySlice.java index 6a6d89d9..7c8a8b11 100644 --- a/entry/src/main/java/com/dbflow5/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/dbflow5/slice/MainAbilitySlice.java @@ -1,3 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.dbflow5.slice; import com.dbflow5.ResourceTable; diff --git a/lib/src/main/java/com/dbflow5/query/cache/ModelCache.java b/lib/src/main/java/com/dbflow5/query/cache/ModelCache.java index a77c20af..bf7895ff 100644 --- a/lib/src/main/java/com/dbflow5/query/cache/ModelCache.java +++ b/lib/src/main/java/com/dbflow5/query/cache/ModelCache.java @@ -9,7 +9,7 @@ import com.dbflow5.database.FlowCursor; * Description: A generic cache for models that is implemented or can be implemented to your liking. */ public abstract class ModelCache { - CacheClass cache; + public CacheClass cache; public ModelCache(CacheClass cache) { this.cache = cache; diff --git a/processor/src/main/java/com/dbflow5/processor/Handlers.java b/processor/src/main/java/com/dbflow5/processor/Handlers.java index a0bb08a4..f089f8ae 100644 --- a/processor/src/main/java/com/dbflow5/processor/Handlers.java +++ b/processor/src/main/java/com/dbflow5/processor/Handlers.java @@ -1,23 +1,10 @@ package com.dbflow5.processor; -import com.dbflow5.annotation.Database; -import com.dbflow5.annotation.ManyToMany; -import com.dbflow5.annotation.Migration; -import com.dbflow5.annotation.ModelView; -import com.dbflow5.annotation.MultipleManyToMany; -import com.dbflow5.annotation.QueryModel; -import com.dbflow5.annotation.Table; -import com.dbflow5.annotation.TypeConverter; +import com.dbflow5.annotation.*; import com.dbflow5.contentprovider.annotation.ContentProvider; import com.dbflow5.contentprovider.annotation.TableEndpoint; import com.dbflow5.converter.TypeConverters; -import com.dbflow5.processor.definition.DatabaseDefinition; -import com.dbflow5.processor.definition.ManyToManyDefinition; -import com.dbflow5.processor.definition.MigrationDefinition; -import com.dbflow5.processor.definition.ModelViewDefinition; -import com.dbflow5.processor.definition.QueryModelDefinition; -import com.dbflow5.processor.definition.TableDefinition; -import com.dbflow5.processor.definition.TypeConverterDefinition; +import com.dbflow5.processor.definition.*; import com.dbflow5.processor.definition.provider.ContentProviderDefinition; import com.dbflow5.processor.definition.provider.TableEndpointDefinition; import com.dbflow5.processor.utils.ProcessorUtils; @@ -66,9 +53,11 @@ public class Handlers { processElements(processorManager, annotatedElements); if (annotatedElements.size() > 0) { annotatedElements.forEach(element -> { - AnnotationClass annotation = element.getAnnotation(annotationClass); - if (annotation != null) { - onProcessElement(annotation, element, processorManager); + if(element != null) { + AnnotationClass annotation = element.getAnnotation(annotationClass); + if (annotation != null) { + onProcessElement(annotation, element, processorManager); + } } }); afterProcessElements(processorManager); @@ -266,7 +255,7 @@ public class Handlers { }; } - static class ContentProviderHandler extends Handlers.AnnotatedHandler { + static class ContentProviderHandler extends AnnotatedHandler { public ContentProviderHandler() { super(ContentProvider.class); @@ -284,7 +273,7 @@ public class Handlers { /** * Description: Deals with writing database definitions */ - public static class DatabaseHandler extends Handlers.AnnotatedHandler { + public static class DatabaseHandler extends AnnotatedHandler { private final Validators.DatabaseValidator validator = new Validators.DatabaseValidator(); diff --git a/processor/src/main/java/com/dbflow5/processor/ProcessorManager.java b/processor/src/main/java/com/dbflow5/processor/ProcessorManager.java index 9939a0ca..d51d079e 100644 --- a/processor/src/main/java/com/dbflow5/processor/ProcessorManager.java +++ b/processor/src/main/java/com/dbflow5/processor/ProcessorManager.java @@ -2,25 +2,14 @@ package com.dbflow5.processor; import com.dbflow5.MapUtils; import com.dbflow5.StringUtils; -import com.dbflow5.processor.definition.DatabaseDefinition; -import com.dbflow5.processor.definition.DatabaseHolderDefinition; -import com.dbflow5.processor.definition.DatabaseObjectHolder; -import com.dbflow5.processor.definition.EntityDefinition; -import com.dbflow5.processor.definition.ManyToManyDefinition; -import com.dbflow5.processor.definition.MigrationDefinition; -import com.dbflow5.processor.definition.ModelViewDefinition; -import com.dbflow5.processor.definition.QueryModelDefinition; -import com.dbflow5.processor.definition.TableDefinition; -import com.dbflow5.processor.definition.TypeConverterDefinition; +import com.dbflow5.processor.definition.*; import com.dbflow5.processor.definition.provider.ContentProviderDefinition; import com.dbflow5.processor.definition.provider.TableEndpointDefinition; import com.dbflow5.processor.utils.WriterUtils; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.TypeName; -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; + import javax.annotation.processing.FilerException; import javax.annotation.processing.Messager; import javax.annotation.processing.ProcessingEnvironment; @@ -29,6 +18,9 @@ import javax.lang.model.element.Element; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; import javax.tools.Diagnostic; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; /** * Description: The main object graph during processing. This class collects all of the @@ -81,7 +73,7 @@ public class ProcessorManager implements Handlers.Handler { } public List getDatabaseHolderDefinitionList() { - return (List) databaseDefinitionMap.values(); + return new ArrayList<>(databaseDefinitionMap.values()); } public DatabaseObjectHolder getDatabaseHolderDefinition(TypeName databaseName) { @@ -368,7 +360,7 @@ public class ProcessorManager implements Handlers.Handler { try { DatabaseHolderDefinition databaseHolderDefinition = new DatabaseHolderDefinition(processorManager); if (!databaseHolderDefinition.isGarbage()) { - JavaFile.builder(com.dbflow5.processor.ClassNames.FLOW_MANAGER_PACKAGE, + JavaFile.builder(ClassNames.FLOW_MANAGER_PACKAGE, databaseHolderDefinition.typeSpec()).build() .writeTo(processorManager.processingEnvironment.getFiler()); } diff --git a/processor/src/main/java/com/dbflow5/processor/definition/Methods.java b/processor/src/main/java/com/dbflow5/processor/definition/Methods.java index e2461308..1850c9a9 100644 --- a/processor/src/main/java/com/dbflow5/processor/definition/Methods.java +++ b/processor/src/main/java/com/dbflow5/processor/definition/Methods.java @@ -12,13 +12,13 @@ import com.dbflow5.processor.utils.JavaPoetExtensions; import com.dbflow5.processor.utils.ModelUtils; import com.squareup.javapoet.*; +import javax.lang.model.element.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import javax.lang.model.element.Modifier; /** * Description: @@ -615,7 +615,7 @@ public class Methods{ @Override public MethodSpec methodSpec() { boolean shouldWrite = tableDefinition.oneToManyDefinitions.stream().anyMatch(OneToManyDefinition::isDelete); - if (shouldWrite || tableDefinition.cachingBehavior().cachingEnabled) { + if (shouldWrite || tableDefinition.cachingBehavior.cachingEnabled) { TypeName returnTypeName = isPlural? TypeName.LONG : TypeName.BOOLEAN; MethodSpec.Builder methodBuilder = MethodSpec @@ -626,7 +626,7 @@ public class Methods{ .addModifiers(Modifier.PUBLIC, Modifier.FINAL) .addParameter(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper); - if (tableDefinition.cachingBehavior().cachingEnabled) { + if (tableDefinition.cachingBehavior.cachingEnabled) { methodBuilder.addStatement("cacheAdapter.removeModel"+(isPlural? "s" : "")+"FromCache("+variableName+")"); } @@ -679,7 +679,7 @@ public class Methods{ @Override public MethodSpec methodSpec() { - if (!tableDefinition.oneToManyDefinitions.isEmpty() || tableDefinition.cachingBehavior().cachingEnabled) { + if (!tableDefinition.oneToManyDefinitions.isEmpty() || tableDefinition.cachingBehavior.cachingEnabled) { TypeName retType = TypeName.BOOLEAN; String retStatement = "successful"; if (isPlural) { @@ -709,7 +709,7 @@ public class Methods{ } codeBuilder.addStatement("super."+fullMethodName+"("+variableName+""+ColumnAccessCombiner.wrapperCommaIfBaseModel(true)+")"); - if (tableDefinition.cachingBehavior().cachingEnabled) { + if (tableDefinition.cachingBehavior.cachingEnabled) { codeBuilder.addStatement("cacheAdapter.storeModel"+(isPlural? "s" : "")+"InCache("+variableName+")"); } diff --git a/processor/src/main/java/com/dbflow5/processor/definition/TableDefinition.java b/processor/src/main/java/com/dbflow5/processor/definition/TableDefinition.java index e0c2e5a6..32b95bb4 100644 --- a/processor/src/main/java/com/dbflow5/processor/definition/TableDefinition.java +++ b/processor/src/main/java/com/dbflow5/processor/definition/TableDefinition.java @@ -19,13 +19,13 @@ import com.dbflow5.processor.utils.ModelUtils; import com.dbflow5.processor.utils.ProcessorUtils; import com.squareup.javapoet.*; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** * Description: Used in writing ModelAdapters @@ -98,8 +98,8 @@ public class TableDefinition extends EntityDefinition { ftsBehavior = null; } - com.dbflow5.annotation.InheritedColumn[] inheritedColumns = table.inheritedColumns(); - for (com.dbflow5.annotation.InheritedColumn it : inheritedColumns) { + InheritedColumn[] inheritedColumns = table.inheritedColumns(); + for (InheritedColumn it : inheritedColumns) { if (inheritedFieldNameList.contains(it.fieldName())) { manager.logError("A duplicate inherited column with name " + it.fieldName() + " " + "was found for " + associationalBehavior().name); @@ -128,6 +128,12 @@ public class TableDefinition extends EntityDefinition { new Methods.BindToContentValuesMethod(this, false, implementsContentValuesListener)}; temporary = table.temporary(); + + cachingBehavior = new Behaviors.CachingBehavior( + table.cachingEnabled(), + table.cacheSize(), + null, + null); } @Override @@ -173,7 +179,6 @@ public class TableDefinition extends EntityDefinition { private Behaviors.AssociationalBehavior associationalBehavior; private Behaviors.CursorHandlingBehavior cursorHandlingBehavior; - private Behaviors.CachingBehavior cachingBehavior; @Override public Behaviors.AssociationalBehavior associationalBehavior() { @@ -198,16 +203,7 @@ public class TableDefinition extends EntityDefinition { return cursorHandlingBehavior; } - public Behaviors.CachingBehavior cachingBehavior() { - if (cachingBehavior == null) { - cachingBehavior = new Behaviors.CachingBehavior( - table.cachingEnabled(), - table.cacheSize(), - null, - null); - } - return cachingBehavior; - } + public Behaviors.CachingBehavior cachingBehavior; public Type type; diff --git a/processor/src/main/java/com/dbflow5/processor/definition/behavior/ComplexColumnBehavior.java b/processor/src/main/java/com/dbflow5/processor/definition/behavior/ComplexColumnBehavior.java index 63ff2c95..bcb3b1ad 100644 --- a/processor/src/main/java/com/dbflow5/processor/definition/behavior/ComplexColumnBehavior.java +++ b/processor/src/main/java/com/dbflow5/processor/definition/behavior/ComplexColumnBehavior.java @@ -10,6 +10,7 @@ import com.squareup.javapoet.ArrayTypeName; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; + import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; @@ -109,29 +110,31 @@ public class ComplexColumnBehavior { private void evaluateTypeConverter(TypeConverterDefinition typeConverter, boolean isCustom) { // Any annotated members, otherwise we will use the scanner to find other ones - if (typeConverter.modelTypeName != columnClassName) { - manager.logError("The specified custom TypeConverter's Model Value " + - "${typeConverter.modelTypeName} from ${typeConverter.className}" + - " must match the type of the column $columnClassName."); - } else { - hasTypeConverter = true; - hasCustomConverter = isCustom; - - String fieldName; - if (hasCustomConverter) { - fieldName = columnDefinition.entityDefinition - .addColumnForCustomTypeConverter(columnDefinition, typeConverter.className); + if(typeConverter != null) { + if (typeConverter.modelTypeName != columnClassName) { + manager.logError("The specified custom TypeConverter's Model Value " + + "${typeConverter.modelTypeName} from ${typeConverter.className}" + + " must match the type of the column $columnClassName."); } else { - fieldName = columnDefinition.entityDefinition - .addColumnForTypeConverter(columnDefinition, typeConverter.className); - } + hasTypeConverter = true; + hasCustomConverter = isCustom; + + String fieldName; + if (hasCustomConverter) { + fieldName = columnDefinition.entityDefinition + .addColumnForCustomTypeConverter(columnDefinition, typeConverter.className); + } else { + fieldName = columnDefinition.entityDefinition + .addColumnForTypeConverter(columnDefinition, typeConverter.className); + } - wrapperAccessor = new ColumnAccessor.TypeConverterScopeColumnAccessor(fieldName, null); - wrapperTypeName = typeConverter.dbTypeName; + wrapperAccessor = new ColumnAccessor.TypeConverterScopeColumnAccessor(fieldName, null); + wrapperTypeName = typeConverter.dbTypeName; - // special case of blob - if (wrapperTypeName == ClassName.get(Blob.class)) { - subWrapperAccessor = new ColumnAccessor.BlobColumnAccessor(null); + // special case of blob + if (wrapperTypeName == ClassName.get(Blob.class)) { + subWrapperAccessor = new ColumnAccessor.BlobColumnAccessor(null); + } } } } diff --git a/processor/src/main/java/com/dbflow5/processor/utils/ElementUtility.java b/processor/src/main/java/com/dbflow5/processor/utils/ElementUtility.java index 056dc074..b1f8e731 100644 --- a/processor/src/main/java/com/dbflow5/processor/utils/ElementUtility.java +++ b/processor/src/main/java/com/dbflow5/processor/utils/ElementUtility.java @@ -3,10 +3,12 @@ package com.dbflow5.processor.utils; import com.dbflow5.annotation.ColumnIgnore; import com.dbflow5.processor.ProcessorManager; import com.squareup.javapoet.ClassName; + import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; +import java.util.ArrayList; import java.util.List; /** @@ -22,8 +24,8 @@ public class ElementUtility { * @return real full-set of elements, including ones from super-class. */ public static List getAllElements(TypeElement element, ProcessorManager manager) { - List elements = (List)manager.elements.getAllMembers(element); - TypeMirror superMirror = null; + List elements = new ArrayList<>(manager.elements.getAllMembers(element)); + TypeMirror superMirror; TypeElement typeElement = element; if(typeElement != null){ superMirror = typeElement.getSuperclass(); @@ -31,11 +33,11 @@ public class ElementUtility { typeElement = (TypeElement)manager.typeUtils.asElement(superMirror); if(typeElement != null){ List superElements = (List)manager.elements.getAllMembers(typeElement); - superElements.forEach(it -> { + for (Element it : superElements) { if (!elements.contains(it)) { elements.add(it); } - }); + } } } } -- Gitee