![JAR search and dependency download from the Maven repository](/logo.png)
net.lecousin.framework.serialization.annotations.MergeAttributes Maven / Gradle / Ivy
The newest version!
package net.lecousin.framework.serialization.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.lecousin.framework.serialization.SerializationContextPattern;
import net.lecousin.framework.serialization.SerializationClass.Attribute;
import net.lecousin.framework.serialization.rules.MergeTypeAttributes;
import net.lecousin.framework.serialization.rules.SerializationRule;
/** Merge into an attribute all other attributes to create a single object. */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.METHOD,ElementType.TYPE})
public @interface MergeAttributes {
/** Type to merge from. */
Class> type();
/** Target attribute. */
String target();
/** Convert an annotation into a rule. */
public static class ToRule implements AttributeAnnotationToRuleOnType {
@Override
public SerializationRule createRule(MergeAttributes annotation, Attribute attribute) {
return new MergeTypeAttributes(
new SerializationContextPattern.OnClassAttribute(attribute.getDeclaringClass(), attribute.getOriginalName()),
annotation.type(), annotation.target());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy