AnnotationUsageBase(AnnotationUsage prototype) { type = prototype.getType(); value = prototype.getValue().map(Copier::copy).orElse(null); values = Copier.copy(prototype.getValues(), e -> new AbstractMap.SimpleEntry<>( e.getKey(), e.getValue().copy() ) ); }
@Override public Optional<String> transform(Generator gen, AnnotationUsage model) { requireNonNull(gen); requireNonNull(model); final Optional<String> value = gen.on(model.getValue()); final Stream<String> valueStream = value.map(Stream::of).orElseGet(Stream::empty); return Optional.of( "@" + gen.on(model.getType()).orElseThrow(NoSuchElementException::new) + Stream.of( model.getValues().stream() .map(e -> e.getKey() + gen.on(e.getValue()) .map(s -> " = " + s) .orElse("") ), valueStream ).flatMap(s -> s).collect( joinIfNotEmpty(", ", "(", ")") ) ); } }
addType(a.getType(), types); a.getValue().ifPresent(v -> findTypesIn(v, types)); a.getValues().stream() .map(Map.Entry::getValue) .forEach(v -> findTypesIn(v, types));
AnnotationUsageBase(AnnotationUsage prototype) { type = prototype.getType(); value = prototype.getValue().map(Copier::copy).orElse(null); values = Copier.copy(prototype.getValues(), e -> new AbstractMap.SimpleEntry<>( e.getKey(), e.getValue().copy() ) ); }
AnnotationUsageBase(AnnotationUsage prototype) { type = prototype.getType(); value = prototype.getValue().map(Copier::copy).orElse(null); values = Copier.copy(prototype.getValues(), e -> new AbstractMap.SimpleEntry<>( e.getKey(), e.getValue().copy() ) ); }
@Override public Optional<String> transform(Generator gen, AnnotationUsage model) { requireNonNull(gen); requireNonNull(model); final Optional<String> value = gen.on(model.getValue()); final Stream<String> valueStream = value.map(Stream::of).orElseGet(Stream::empty); return Optional.of( "@" + gen.on(model.getType()).orElseThrow(NoSuchElementException::new) + Stream.of( model.getValues().stream() .map(e -> e.getKey() + gen.on(e.getValue()) .map(s -> " = " + s) .orElse("") ), valueStream ).flatMap(s -> s).collect( joinIfNotEmpty(", ", "(", ")") ) ); } }
@Override public Optional<String> transform(Generator gen, AnnotationUsage model) { requireNonNull(gen); requireNonNull(model); final Optional<String> value = gen.on(model.getValue()); final Stream<String> valueStream = value.isPresent() ? Stream.of(value.get()) : Stream.empty(); return Optional.of( "@" + gen.on(model.getType()).get() + Stream.of( model.getValues().stream() .map(e -> e.getKey() + gen.on(e.getValue()) .map(s -> " = " + s) .orElse("") ), valueStream ).flatMap(s -> s).collect( joinIfNotEmpty(", ", "(", ")") ) ); } }
addType(a.getType(), types); a.getValue().ifPresent(v -> findTypesIn(v, types)); a.getValues().stream() .map(Map.Entry::getValue) .forEach(v -> findTypesIn(v, types));