diff --git a/src/main/java/org/burningwave/core/Criteria.java b/src/main/java/org/burningwave/core/Criteria.java index 523007c18..d211d0faf 100644 --- a/src/main/java/org/burningwave/core/Criteria.java +++ b/src/main/java/org/burningwave/core/Criteria.java @@ -437,13 +437,15 @@ > Predicate consumeLogicalOperator ( Function, Predicate> logicalOperator ) { + int methodIndex = 10; + int messageIndex = 11; return Optional.ofNullable(logicalOperator).map(logOp -> { return logicalOperator.apply(input); }).orElseGet(() -> org.burningwave.core.assembler.StaticComponentContainer.Driver.throwException( "A call to and/or method is necessary before calling {} at {}", - Thread.currentThread().getStackTrace()[10].getMethodName(), - Thread.currentThread().getStackTrace()[11] + Thread.currentThread().getStackTrace()[methodIndex].getMethodName(), + Thread.currentThread().getStackTrace()[messageIndex] ) ); } diff --git a/src/main/java/org/burningwave/core/StringUtils.java b/src/main/java/org/burningwave/core/StringUtils.java new file mode 100644 index 000000000..f1fd39941 --- /dev/null +++ b/src/main/java/org/burningwave/core/StringUtils.java @@ -0,0 +1,46 @@ +package org.burningwave.core; + +public class StringUtils { + + public static String capitalizeFirstCharacter(String value) { + return Character.toString(value.charAt(0)).toUpperCase() + + value.substring(1, value.length()); + } + + public static boolean isBlank(String str) { + int strLen; + if ((str == null) || ((strLen = str.length()) == 0)) { + return true; + } + for (int i = 0; i < strLen; ++i) { + if (!(Character.isWhitespace(str.charAt(i)))) { + return false; + } + } + return true; + } + + public static boolean isNotBlank(String str) { + return (!(isBlank(str))); + } + + public static boolean isEmpty(String str) { + return ((str == null) || (str.length() == 0)); + } + + public static boolean isNotEmpty(String str) { + return (!(isEmpty(str))); + } + + public static boolean contains(String str, char searchChar) { + if (isEmpty(str)) { + return false; + } + return (str.indexOf(searchChar) >= 0); + } + + public static boolean areEquals(String string1, String string2) { + return (isEmpty(string1) && isEmpty(string2)) || + (isNotEmpty(string1) && isNotEmpty(string2) && string1.equals(string2)); + } +} diff --git a/src/main/java/org/burningwave/core/Strings.java b/src/main/java/org/burningwave/core/Strings.java index 11a538450..30c576cc8 100644 --- a/src/main/java/org/burningwave/core/Strings.java +++ b/src/main/java/org/burningwave/core/Strings.java @@ -28,6 +28,7 @@ */ package org.burningwave.core; +import static org.burningwave.core.StringUtils.isEmpty; import static org.burningwave.core.assembler.StaticComponentContainer.ManagedLoggerRepository; import java.net.URLDecoder; @@ -58,45 +59,6 @@ public static Strings create() { return new Strings(); } - public String capitalizeFirstCharacter(String value) { - return Character.toString(value.charAt(0)).toUpperCase() - + value.substring(1, value.length()); - } - - public boolean isBlank(String str) { - int strLen; - if ((str == null) || ((strLen = str.length()) == 0)) { - return true; - } - for (int i = 0; i < strLen; ++i) { - if (!(Character.isWhitespace(str.charAt(i)))) { - return false; - } - } - return true; - } - - public boolean isNotBlank(String str) { - return (!(isBlank(str))); - } - - - public boolean isEmpty(String str) { - return ((str == null) || (str.length() == 0)); - } - - public boolean isNotEmpty(String str) { - return (!(isEmpty(str))); - } - - - public boolean contains(String str, char searchChar) { - if (isEmpty(str)) { - return false; - } - return (str.indexOf(searchChar) >= 0); - } - public String strip(String str, String stripChars) { if (isEmpty(str)) { @@ -390,10 +352,7 @@ public String removeInitialPathElements(String path, String... toRemove) { } - public boolean areEquals(String string1, String string2) { - return (isEmpty(string1) && isEmpty(string2)) || - (isNotEmpty(string1) && isNotEmpty(string2) && string1.equals(string2)); - } + public String placeHolderToRegEx(String value) { return value.replace("$", "\\$").replace(".", "\\.").replace("{", "\\{").replace("}", "\\}"); diff --git a/src/main/java/org/burningwave/core/classes/AnnotationSourceGenerator.java b/src/main/java/org/burningwave/core/classes/AnnotationSourceGenerator.java index 3f7b4194d..6353db815 100644 --- a/src/main/java/org/burningwave/core/classes/AnnotationSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/AnnotationSourceGenerator.java @@ -56,7 +56,9 @@ public static AnnotationSourceGenerator create(Class cls) { return annotation; } - Collection getTypeDeclarations() { + + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(body).ifPresent(hirearchyElements -> { types.addAll(body.getTypeDeclarations()); diff --git a/src/main/java/org/burningwave/core/classes/BodySourceGenerator.java b/src/main/java/org/burningwave/core/classes/BodySourceGenerator.java index 3abfb16d2..4127bedae 100644 --- a/src/main/java/org/burningwave/core/classes/BodySourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/BodySourceGenerator.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Optional; @SuppressWarnings("unchecked") @@ -99,6 +100,11 @@ public BodySourceGenerator addCode(String... elements) { public String make() { return element; } + + @Override + public Collection getTypeDeclarations(){ + return Collections.emptyList(); + } }); } return this; @@ -127,33 +133,13 @@ public BodySourceGenerator addAllElements(Collection return this; } - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(usedTypes).ifPresent(usedTypes -> types.addAll(usedTypes)); Optional.ofNullable(bodyGenerators).ifPresent(bodyGenerators -> { for (SourceGenerator generator : bodyGenerators) { - if (generator instanceof AnnotationSourceGenerator) { - types.addAll(((AnnotationSourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof BodySourceGenerator) { - types.addAll(((BodySourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof ClassSourceGenerator) { - types.addAll(((ClassSourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof FunctionSourceGenerator) { - types.addAll(((FunctionSourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof GenericSourceGenerator) { - types.addAll(((GenericSourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof TypeDeclarationSourceGenerator) { - types.addAll(((TypeDeclarationSourceGenerator)generator).getTypeDeclarations()); - } - if (generator instanceof VariableSourceGenerator) { - types.addAll(((VariableSourceGenerator)generator).getTypeDeclarations()); - } - + types.addAll(generator.getTypeDeclarations()); } }); return types; diff --git a/src/main/java/org/burningwave/core/classes/ClassPathHelper.java b/src/main/java/org/burningwave/core/classes/ClassPathHelper.java index 8b7b33f89..ebd5f2dd3 100644 --- a/src/main/java/org/burningwave/core/classes/ClassPathHelper.java +++ b/src/main/java/org/burningwave/core/classes/ClassPathHelper.java @@ -37,6 +37,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; +import org.burningwave.core.StringUtils; import org.burningwave.core.io.FileSystemItem; public interface ClassPathHelper { @@ -132,7 +133,7 @@ public static AndAddToClassLoaderConfig create( if (classRepositories == null) { throw new IllegalArgumentException("No class repository has been provided"); } - if (Strings.isEmpty(nameOfTheClassToBeLoaded)) { + if (StringUtils.isEmpty(nameOfTheClassToBeLoaded)) { throw new IllegalArgumentException("No class name to be found has been provided"); } return new AndAddToClassLoaderConfig(classLoader, classRepositories, nameOfTheClassToBeLoaded); diff --git a/src/main/java/org/burningwave/core/classes/ClassSourceGenerator.java b/src/main/java/org/burningwave/core/classes/ClassSourceGenerator.java index 34b13ba32..aadbf816a 100644 --- a/src/main/java/org/burningwave/core/classes/ClassSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/ClassSourceGenerator.java @@ -62,7 +62,8 @@ private ClassSourceGenerator(String classType, TypeDeclarationSourceGenerator ty this.typeDeclaration = typeDeclaration; } - TypeDeclarationSourceGenerator getTypeDeclaration() { + + public TypeDeclarationSourceGenerator getTypeDeclaration() { return typeDeclaration; } @@ -326,7 +327,8 @@ String getOuterCode() { ).orElseGet(() -> null); } - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = typeDeclaration.getTypeDeclarations(); Optional.ofNullable(staticInitializer).ifPresent(stcInit -> { types.addAll(stcInit.getTypeDeclarations()); diff --git a/src/main/java/org/burningwave/core/classes/CodeExecutorImpl.java b/src/main/java/org/burningwave/core/classes/CodeExecutorImpl.java index dbb9c0d38..a024fba46 100644 --- a/src/main/java/org/burningwave/core/classes/CodeExecutorImpl.java +++ b/src/main/java/org/burningwave/core/classes/CodeExecutorImpl.java @@ -32,7 +32,6 @@ import static org.burningwave.core.assembler.StaticComponentContainer.ClassLoaders; import static org.burningwave.core.assembler.StaticComponentContainer.Constructors; import static org.burningwave.core.assembler.StaticComponentContainer.IterableObjectHelper; -import static org.burningwave.core.assembler.StaticComponentContainer.Strings; import java.util.Collection; import java.util.Map; @@ -41,6 +40,7 @@ import org.burningwave.core.Component; import org.burningwave.core.Executable; +import org.burningwave.core.StringUtils; import org.burningwave.core.io.FileSystemItem; import org.burningwave.core.io.PathHelper; import org.burningwave.core.iterable.IterableObjectHelper.ResolveConfig; @@ -124,9 +124,9 @@ public , T> T execute(ExecuteConfig.ForProperties con Configuration.Key.PROPERTIES_FILE_SUPPLIER_SIMPLE_NAME_SUFFIX, Configuration.Key.PROPERTIES_FILE_EXECUTOR_SIMPLE_NAME_SUFFIX ); - if (Strings.isNotEmpty(executorName)) { + if (StringUtils.isNotEmpty(executorName)) { config.setName(executorName); - } else if (Strings.isNotEmpty(executorSimpleName)) { + } else if (StringUtils.isNotEmpty(executorSimpleName)) { config.setSimpleName(executorSimpleName); } String code = IterableObjectHelper.resolveStringValue( @@ -139,7 +139,7 @@ public , T> T execute(ExecuteConfig.ForProperties con if (config.isIndentCodeActive()) { code = code.replaceAll(";{2,}", ";"); for (String codeLine : code.split(";")) { - if (Strings.isNotEmpty(codeLine)) { + if (StringUtils.isNotEmpty(codeLine)) { body.addCodeLine(codeLine + ";"); } } diff --git a/src/main/java/org/burningwave/core/classes/FieldAccessor.java b/src/main/java/org/burningwave/core/classes/FieldAccessor.java index 79b36412d..6479c395f 100644 --- a/src/main/java/org/burningwave/core/classes/FieldAccessor.java +++ b/src/main/java/org/burningwave/core/classes/FieldAccessor.java @@ -267,7 +267,9 @@ Boolean setFieldByDirectAccess(Object target, String pathSegment, Object value) Field field = Fields.findOneAndMakeItAccessible(target.getClass(), matcher.group(1)); Fields.setDirect(target, field, value); } else { - if (target.getClass().isArray() || target instanceof Map || target instanceof Collection) { + boolean isArray = target.getClass().isArray(); + boolean isMapOrCollection = target instanceof Map || target instanceof Collection; + if ( isArray || isMapOrCollection) { setInIndexedField(target, matcher.group(2), value); } else { Field field = Fields.findOneAndMakeItAccessible(target.getClass(), matcher.group(1)); diff --git a/src/main/java/org/burningwave/core/classes/FunctionSourceGenerator.java b/src/main/java/org/burningwave/core/classes/FunctionSourceGenerator.java index 0424e9524..b54a052c5 100644 --- a/src/main/java/org/burningwave/core/classes/FunctionSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/FunctionSourceGenerator.java @@ -199,8 +199,8 @@ private String getParametersCode() { } return paramsCode + ")"; } - - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(usedTypes).ifPresent(usedTypes -> { types.addAll(usedTypes); diff --git a/src/main/java/org/burningwave/core/classes/FunctionalInterfaceFactoryImpl.java b/src/main/java/org/burningwave/core/classes/FunctionalInterfaceFactoryImpl.java index 16823473a..9f6ae1b39 100644 --- a/src/main/java/org/burningwave/core/classes/FunctionalInterfaceFactoryImpl.java +++ b/src/main/java/org/burningwave/core/classes/FunctionalInterfaceFactoryImpl.java @@ -125,31 +125,44 @@ private Method retrieveMethod(Class targetClass, String methodName, Class. @Override public F getOrCreate(Executable executable) { if (executable instanceof Method) { - Method targetMethod = (Method)executable; - if (targetMethod.getParameterTypes().length == 0 && targetMethod.getReturnType() == void.class) { - return getOrCreateBindedRunnable(targetMethod); - } else if ((targetMethod.getReturnType() == boolean.class || targetMethod.getReturnType() == Boolean.class) && - (targetMethod.getParameterTypes().length > 0 || (targetMethod.getParameterTypes().length == 0 && !Modifier.isStatic(targetMethod.getModifiers()))) - ) { - return getOrCreateBindedPredicate(targetMethod); - } else if (targetMethod.getParameterTypes().length == 0 && targetMethod.getReturnType() != void.class) { - return getOrCreateBindedSupplier(targetMethod); - } else if (targetMethod.getParameterTypes().length > 0 && targetMethod.getReturnType() == void.class) { - return getOrCreateBindedConsumer(targetMethod); - } else if (targetMethod.getParameterTypes().length > 0 && targetMethod.getReturnType() != void.class) { - return getOrCreateBindedFunction(targetMethod); - } + return getOrCreateMethod(executable); } else if (executable instanceof Constructor) { - Constructor targetConstructor = (Constructor)executable; - if (targetConstructor.getParameterTypes().length == 0) { - return getOrCreateBindedSupplier(targetConstructor); - } else { - return getOrCreateBindedFunction(targetConstructor); - } + return getOrCreateConstructor(executable); } return null; } + public F getOrCreateConstructor(Executable executable){ + Constructor targetConstructor = (Constructor)executable; + + if (targetConstructor.getParameterTypes().length == 0) { + return getOrCreateBindedSupplier(targetConstructor); + } + + return getOrCreateBindedFunction(targetConstructor); + } + + public F getOrCreateMethod(Executable executable){ + Method targetMethod = (Method)executable; + + boolean isBoolean = (targetMethod.getReturnType() == boolean.class || targetMethod.getReturnType() == Boolean.class); + boolean hasParameters = targetMethod.getParameterTypes().length > 0; + boolean hasNoParametersAndNoStaticModifiers = targetMethod.getParameterTypes().length == 0 && !Modifier.isStatic(targetMethod.getModifiers()); + + + if (targetMethod.getParameterTypes().length == 0 && targetMethod.getReturnType() == void.class) { + return getOrCreateBindedRunnable(targetMethod); + } else if ( isBoolean && ( hasParameters || (hasNoParametersAndNoStaticModifiers))) { + return getOrCreateBindedPredicate(targetMethod); + } else if (targetMethod.getParameterTypes().length == 0 && targetMethod.getReturnType() != void.class) { + return getOrCreateBindedSupplier(targetMethod); + } else if (targetMethod.getParameterTypes().length > 0 && targetMethod.getReturnType() == void.class) { + return getOrCreateBindedConsumer(targetMethod); + } else if (targetMethod.getParameterTypes().length > 0 && targetMethod.getReturnType() != void.class) { + return getOrCreateBindedFunction(targetMethod); + } + return null; + } F getOrCreateBindedRunnable(Executable executable) { return (F) Cache.bindedFunctionalInterfaces.getOrUploadIfAbsent( Classes.getClassLoader(executable.getDeclaringClass()), diff --git a/src/main/java/org/burningwave/core/classes/GenericSourceGenerator.java b/src/main/java/org/burningwave/core/classes/GenericSourceGenerator.java index 9e4627c7f..a41170055 100644 --- a/src/main/java/org/burningwave/core/classes/GenericSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/GenericSourceGenerator.java @@ -93,7 +93,8 @@ public GenericSourceGenerator parentOf(TypeDeclarationSourceGenerator hirearchyE return this; } - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(annotations).ifPresent(annotations -> { for (AnnotationSourceGenerator annotation : annotations) { diff --git a/src/main/java/org/burningwave/core/classes/JavaMemoryCompilerImpl.java b/src/main/java/org/burningwave/core/classes/JavaMemoryCompilerImpl.java index a60d72f8c..19c9b0823 100644 --- a/src/main/java/org/burningwave/core/classes/JavaMemoryCompilerImpl.java +++ b/src/main/java/org/burningwave/core/classes/JavaMemoryCompilerImpl.java @@ -70,6 +70,7 @@ import org.burningwave.core.Closeable; import org.burningwave.core.Component; +import org.burningwave.core.StringUtils; import org.burningwave.core.classes.ClassPathHelper.Compute; import org.burningwave.core.classes.JavaMemoryCompiler.Compilation.Config; import org.burningwave.core.concurrent.QueuedTaskExecutor.ProducerTask; @@ -340,7 +341,7 @@ public void report(Diagnostic diagnostic) { } } } - if (Strings.isNotEmpty(packageName)) { + if (StringUtils.isNotEmpty(packageName)) { try { fsObjects = context.findForPackageName(packageName); } catch (Exception exc) { @@ -561,7 +562,7 @@ static Context create( } void addToClassPath(String path) { - if (Strings.isNotBlank(path)) { + if (StringUtils.isNotBlank(path)) { if (blackListedClassPaths.contains(path)) { ManagedLoggerRepository.logWarn(getClass()::getName, "Could not add {} to class path because it is black listed", path); return; diff --git a/src/main/java/org/burningwave/core/classes/MemoryClassLoader.java b/src/main/java/org/burningwave/core/classes/MemoryClassLoader.java index 1600e1a9f..352e474d3 100644 --- a/src/main/java/org/burningwave/core/classes/MemoryClassLoader.java +++ b/src/main/java/org/burningwave/core/classes/MemoryClassLoader.java @@ -59,6 +59,7 @@ import org.burningwave.core.Closeable; import org.burningwave.core.Component; +import org.burningwave.core.StringUtils; import org.burningwave.core.classes.Classes.Loaders.ChangeParentsContext; import org.burningwave.core.concurrent.QueuedTaskExecutor; import org.burningwave.core.io.ByteBufferInputStream; @@ -205,7 +206,7 @@ public void addByteCodes(Entry... classes) { } public boolean hasPackageBeenDefined(String packageName) { - return Strings.isEmpty(packageName) || ClassLoaders.retrieveLoadedPackage(this, packageName) != null; + return StringUtils.isEmpty(packageName) || ClassLoaders.retrieveLoadedPackage(this, packageName) != null; } @Override @@ -214,7 +215,7 @@ protected Package definePackage(String packageName, String specTitle, String implVersion, String implVendor, URL sealBase ) throws IllegalArgumentException { Package pkg = null; - if (Strings.isNotEmpty(packageName)) { + if (StringUtils.isNotEmpty(packageName)) { try { pkg = super.definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); diff --git a/src/main/java/org/burningwave/core/classes/Methods.java b/src/main/java/org/burningwave/core/classes/Methods.java index 13e9c39fe..d75121b56 100644 --- a/src/main/java/org/burningwave/core/classes/Methods.java +++ b/src/main/java/org/burningwave/core/classes/Methods.java @@ -47,6 +47,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import org.burningwave.core.StringUtils; import org.burningwave.core.function.Executor; import org.burningwave.core.function.ThrowingFunction; @@ -59,13 +60,13 @@ public static Methods create() { String createGetterMethodNameByFieldPath(String fieldPath) { String methodName = - "get" + Strings.capitalizeFirstCharacter(fieldPath); + "get" + StringUtils.capitalizeFirstCharacter(fieldPath); return methodName; } String createSetterMethodNameByFieldPath(String fieldPath) { String methodName = - "set" + Strings.capitalizeFirstCharacter(fieldPath); + "set" + StringUtils.capitalizeFirstCharacter(fieldPath); return methodName; } diff --git a/src/main/java/org/burningwave/core/classes/PojoSourceGenerator.java b/src/main/java/org/burningwave/core/classes/PojoSourceGenerator.java index 30d64df8b..379eeeb6c 100644 --- a/src/main/java/org/burningwave/core/classes/PojoSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/PojoSourceGenerator.java @@ -46,6 +46,7 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; +import org.burningwave.core.StringUtils; import org.burningwave.core.function.PentaConsumer; import org.burningwave.core.function.TriConsumer; @@ -141,7 +142,7 @@ public ClassSourceGenerator generate(String className, int options, Class... if (superClass != null) { String superClassPackage = Optional.ofNullable(superClass.getPackage()).map(pckg -> pckg.getName()).orElseGet(() -> ""); Predicate modifierTester = - Strings.areEquals(packageName, superClassPackage) ? + StringUtils.areEquals(packageName, superClassPackage) ? executable -> !Modifier.isPrivate(executable.getModifiers()) : executable -> diff --git a/src/main/java/org/burningwave/core/classes/SourceGenerator.java b/src/main/java/org/burningwave/core/classes/SourceGenerator.java index 961f20c86..a4cb72ac3 100644 --- a/src/main/java/org/burningwave/core/classes/SourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/SourceGenerator.java @@ -53,6 +53,8 @@ public default FileSystemItem serializeToPath(String absolutePath) { return Objects.serializeToPath(this, absolutePath); } + public abstract Collection getTypeDeclarations(); + public static S deserializeFromPath(String absolutePath) { return Objects.deserializeFromPath(absolutePath); } diff --git a/src/main/java/org/burningwave/core/classes/TypeDeclarationSourceGenerator.java b/src/main/java/org/burningwave/core/classes/TypeDeclarationSourceGenerator.java index de96461a8..4dc627b94 100644 --- a/src/main/java/org/burningwave/core/classes/TypeDeclarationSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/TypeDeclarationSourceGenerator.java @@ -140,8 +140,8 @@ public TypeDeclarationSourceGenerator addGeneric(GenericSourceGenerator... gener this.generics.addAll(Arrays.asList(generics)); return this; } - - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); types.add(this); Optional.ofNullable(generics).ifPresent(generics -> { diff --git a/src/main/java/org/burningwave/core/classes/UnitSourceGenerator.java b/src/main/java/org/burningwave/core/classes/UnitSourceGenerator.java index c151dbd56..e76ec4d1e 100644 --- a/src/main/java/org/burningwave/core/classes/UnitSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/UnitSourceGenerator.java @@ -131,7 +131,8 @@ private Set getImports() { return new LinkedHashSet<>(imports); } - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(classes).ifPresent(clazzes -> { clazzes.forEach(cls -> { diff --git a/src/main/java/org/burningwave/core/classes/VariableSourceGenerator.java b/src/main/java/org/burningwave/core/classes/VariableSourceGenerator.java index 7db49ea42..0a8c60ff1 100644 --- a/src/main/java/org/burningwave/core/classes/VariableSourceGenerator.java +++ b/src/main/java/org/burningwave/core/classes/VariableSourceGenerator.java @@ -105,7 +105,8 @@ public VariableSourceGenerator addAnnotation(AnnotationSourceGenerator annotatio return this; } - Collection getTypeDeclarations() { + @Override + public Collection getTypeDeclarations() { Collection types = new ArrayList<>(); Optional.ofNullable(annotations).ifPresent(annotations -> { for (AnnotationSourceGenerator annotation : annotations) { diff --git a/src/main/java/org/burningwave/core/concurrent/Thread.java b/src/main/java/org/burningwave/core/concurrent/Thread.java index d50d3e59b..66c1e676e 100644 --- a/src/main/java/org/burningwave/core/concurrent/Thread.java +++ b/src/main/java/org/burningwave/core/concurrent/Thread.java @@ -48,6 +48,7 @@ import org.burningwave.core.Closeable; import org.burningwave.core.Identifiable; +import org.burningwave.core.StringUtils; import org.burningwave.core.function.ThrowingConsumer; import org.burningwave.core.iterable.IterableObjectHelper.ResolveConfig; @@ -235,7 +236,7 @@ public String toString() { "{}{}", super.toString(), Optional.ofNullable(getState()).map(threadState -> - Strings.compile("({})", Strings.capitalizeFirstCharacter(threadState.name().toLowerCase().replace("_", " "))) + Strings.compile("({})", StringUtils.capitalizeFirstCharacter(threadState.name().toLowerCase().replace("_", " "))) ).orElseGet(() -> "") ); } diff --git a/src/main/java/org/burningwave/core/io/FileSystemItem.java b/src/main/java/org/burningwave/core/io/FileSystemItem.java index b4d908437..e37a91d06 100644 --- a/src/main/java/org/burningwave/core/io/FileSystemItem.java +++ b/src/main/java/org/burningwave/core/io/FileSystemItem.java @@ -69,6 +69,7 @@ import java.util.function.Supplier; import java.util.regex.Pattern; +import org.burningwave.core.StringUtils; import org.burningwave.core.classes.JavaClass; import org.burningwave.core.function.Executor; import org.burningwave.core.iterable.IterableObjectHelper.IterationConfig; @@ -126,7 +127,7 @@ static FileSystemItem ofPath(String realAbsolutePath, String conventionedAbsolut final String realAbsolutePathCleaned = Paths.toNormalizedCleanedAbsolutePath(realAbsolutePath); FileSystemItem fileSystemItem = Cache.pathForFileSystemItems.getOrUploadIfAbsent(realAbsolutePathCleaned, () -> { - if (Strings.isNotEmpty(realAbsolutePathCleaned)) { + if (StringUtils.isNotEmpty(realAbsolutePathCleaned)) { return new FileSystemItem(realAbsolutePathCleaned, conventionedAbsolutePath); } return null; diff --git a/src/main/java/org/burningwave/core/io/PathHelperImpl.java b/src/main/java/org/burningwave/core/io/PathHelperImpl.java index 243917134..5f79cdd3e 100644 --- a/src/main/java/org/burningwave/core/io/PathHelperImpl.java +++ b/src/main/java/org/burningwave/core/io/PathHelperImpl.java @@ -59,6 +59,7 @@ import java.util.stream.Collectors; import org.burningwave.core.Component; +import org.burningwave.core.StringUtils; import org.burningwave.core.assembler.StaticComponentContainer; import org.burningwave.core.concurrent.QueuedTaskExecutor; import org.burningwave.core.function.Executor; @@ -210,13 +211,13 @@ public Collection loadAndMapPaths(String pathGroupName, String paths) { Collection groupPaths = ConcurrentHashMap.newKeySet(); synchronized(this) { String currentPropertyPaths = (String)config.get(pathGroupPropertyName); - if (Strings.isNotEmpty(currentPropertyPaths) && Strings.isNotEmpty(paths)) { + if (StringUtils.isNotEmpty(currentPropertyPaths) && StringUtils.isNotEmpty(paths)) { if (!currentPropertyPaths.endsWith(IterableObjectHelper.getDefaultValuesSeparator())) { currentPropertyPaths += IterableObjectHelper.getDefaultValuesSeparator(); } currentPropertyPaths += paths; ((Map)config).put(pathGroupPropertyName, currentPropertyPaths); - } else if (Strings.isNotEmpty(paths)) { + } else if (StringUtils.isNotEmpty(paths)) { currentPropertyPaths = paths; ((Map)config).put(pathGroupPropertyName, currentPropertyPaths); } diff --git a/src/main/java/org/burningwave/core/iterable/IterableObjectHelperImpl.java b/src/main/java/org/burningwave/core/iterable/IterableObjectHelperImpl.java index 2cc355745..327ece171 100644 --- a/src/main/java/org/burningwave/core/iterable/IterableObjectHelperImpl.java +++ b/src/main/java/org/burningwave/core/iterable/IterableObjectHelperImpl.java @@ -58,6 +58,7 @@ import java.util.stream.Stream; import org.burningwave.core.Identifiable; +import org.burningwave.core.StringUtils; import org.burningwave.core.assembler.StaticComponentContainer; import org.burningwave.core.concurrent.QueuedTaskExecutor; import org.burningwave.core.function.ThrowingBiConsumer; @@ -434,7 +435,7 @@ private T resolve( if (value != null && value instanceof String) { String stringValue = (String)value; Collection values = new IterableObjectHelperImpl.ArrayList<>(); - if (!Strings.isEmpty(stringValue)) { + if (!StringUtils.isEmpty(stringValue)) { Map> subProperties = Strings.extractAllGroups(Strings.PLACE_HOLDER_NAME_EXTRACTOR_PATTERN, stringValue); if (!subProperties.isEmpty()) { for (Map.Entry> entry : subProperties.entrySet()) { @@ -591,12 +592,12 @@ public boolean containsValue(Map map, String key, Object object, Map value = defaultValues.get(key); } if (value != null && value instanceof String) { - if (Strings.isEmpty((String)value) && defaultValues != null) { + if (StringUtils.isEmpty((String)value) && defaultValues != null) { value = defaultValues.get(key); } if (value != null && value instanceof String) { String stringValue = (String)value; - if (!Strings.isEmpty(stringValue)) { + if (!StringUtils.isEmpty(stringValue)) { if (object instanceof String) { String objectString = (String)object; if (stringValue.contains(objectString)) { diff --git a/src/test/java/org/burningwave/core/StringsTest.java b/src/test/java/org/burningwave/core/StringsTest.java index 43479beed..079018dee 100644 --- a/src/test/java/org/burningwave/core/StringsTest.java +++ b/src/test/java/org/burningwave/core/StringsTest.java @@ -30,7 +30,7 @@ public void convertURLTestOne() { @Test public void stripTest() { - assertTrue(!Strings.contains(Strings.strip(" Hello! ", " "), ' ')); + assertTrue(!StringUtils.contains(Strings.strip(" Hello! ", " "), ' ')); } @@ -39,6 +39,6 @@ public void replaceTest() { Map parameters = new HashMap<>(); parameters.put("${firstParameter}", "firstParameter"); parameters.put("${secondParameter}", "secondParameter"); - assertTrue(!Strings.contains(Strings.replace("${firstParameter},${secondParameter}", parameters), '$')); + assertTrue(!StringUtils.contains(Strings.replace("${firstParameter},${secondParameter}", parameters), '$')); } }