modifieds example to creates less cognitive load for a reader (#8018)

This commit is contained in:
Devender Kumar
2019-10-15 04:24:18 +02:00
committed by maibin
parent 10a7723cf7
commit 3e4c964e6a
7 changed files with 21 additions and 24 deletions

View File

@@ -5,10 +5,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
@Configuration
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ,
pattern = "com.baeldung.componentscan.filter.aspectj.* "
+ "&& !(com.baeldung.componentscan.filter.aspectj.L* "
+ "|| com.baeldung.componentscan.filter.aspectj.C*)"))
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ,
pattern = "com.baeldung.componentscan.filter.aspectj.* "
+ "&& !(com.baeldung.componentscan.filter.aspectj.L* "
+ "|| com.baeldung.componentscan.filter.aspectj.C*)"))
public class ComponentScanAspectJFilterApp {
public static void main(String[] args) {
}

View File

@@ -1,4 +1,4 @@
package com.baeldung.componentscan.filter.custom;
public class Cat extends Pet {
public class Cat {
}

View File

@@ -12,11 +12,8 @@ public class ComponentScanCustomFilter implements TypeFilter {
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
ClassMetadata classMetadata = metadataReader.getClassMetadata();
String superClass = classMetadata.getSuperClassName();
if (Pet.class.getName()
.equalsIgnoreCase(superClass)) {
return true;
}
return false;
String fullyQualifiedName = classMetadata.getClassName();
String className = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".") + 1);
return className.length() > 5 ? true : false;
}
}

View File

@@ -1,4 +1,4 @@
package com.baeldung.componentscan.filter.custom;
public class Pet {
public class Elephant {
}

View File

@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
@Configuration
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*[t]"))
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*(nt)"))
public class ComponentScanRegexFilterApp {
public static void main(String[] args) {