io.micronaut.core.reflect.InstantiationUtils Java Examples
The following examples show how to use
io.micronaut.core.reflect.InstantiationUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPersistentEntity.java From micronaut-data with Apache License 2.0 | 6 votes |
@NonNull private Optional<NamingStrategy> getNamingStrategy(String name) { NamingStrategy namingStrategy = NAMING_STRATEGIES.get(name); if (namingStrategy != null) { return Optional.of(namingStrategy); } else { Object o = InstantiationUtils.tryInstantiate(name, getClass().getClassLoader()).orElse(null); if (o instanceof NamingStrategy) { NamingStrategy ns = (NamingStrategy) o; NAMING_STRATEGIES.put(name, ns); return Optional.of(ns); } return Optional.empty(); } }
Example #2
Source File: AnnotatedRequestHandler.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Override default boolean canHandle(HandlerInput handlerInput) { final Class<? extends AnnotatedRequestHandler> type = getClass(); final String annotationMetadata = type.getPackage().getName() + ".$" + type.getSimpleName() + "DefinitionClass"; final AnnotationMetadata metadata = ClassUtils.forName(annotationMetadata, type.getClassLoader()).flatMap(aClass -> { final Object o = InstantiationUtils.tryInstantiate(aClass).orElse(null); if (o instanceof AnnotationMetadataProvider) { return Optional.of(((AnnotationMetadataProvider) o).getAnnotationMetadata()); } return Optional.empty(); }).orElse(AnnotationMetadata.EMPTY_METADATA); final String[] names = metadata.getValue(IntentHandler.class, String[].class).orElse(StringUtils.EMPTY_STRING_ARRAY); return Arrays.stream(names).anyMatch(n -> handlerInput.matches(intentName(n))); }
Example #3
Source File: MappedEntityVisitor.java From micronaut-data with Apache License 2.0 | 5 votes |
private NamingStrategy resolveNamingStrategy(ClassElement element) { return element.stringValue(MappedEntity.class, "namingStrategy") .flatMap(new Function<String, Optional<NamingStrategy>>() { @Override public Optional<NamingStrategy> apply(String s) { Object o = InstantiationUtils.tryInstantiate(s, getClass().getClassLoader()).orElse(null); if (o instanceof NamingStrategy) { return Optional.of((NamingStrategy) o); } return Optional.empty(); } }).orElseGet(NamingStrategies.UnderScoreSeparatedLowerCase::new); }
Example #4
Source File: AbstractPersistentEntity.java From micronaut-data with Apache License 2.0 | 5 votes |
@NonNull private NamingStrategy getNamingStrategy(AnnotationMetadata annotationMetadata) { return annotationMetadata .classValue(MappedEntity.class, "namingStrategy") .flatMap(aClass -> { @SuppressWarnings("unchecked") Object o = InstantiationUtils.tryInstantiate(aClass).orElse(null); if (o instanceof NamingStrategy) { return Optional.of((NamingStrategy) o); } return Optional.empty(); }).orElseGet(() -> annotationMetadata.stringValue(MappedEntity.class, "namingStrategy").flatMap(this::getNamingStrategy).orElse(new NamingStrategies.UnderScoreSeparatedLowerCase())); }
Example #5
Source File: KafkaSubstitutions.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Substitute public Checksum create() { return (Checksum) InstantiationUtils.instantiate("java.util.zip.CRC32C", getClass().getClassLoader()); }