
net.projectmonkey.object.mapper.annotations.group.Group Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of object-mapper Show documentation
Show all versions of object-mapper Show documentation
Object mapping implementation written as an alternative to modelmapper which is able to support inheritance, handles flattening / expanding in a precise way, and is extensible / configurable
The newest version!
package net.projectmonkey.object.mapper.annotations.group;
import net.projectmonkey.object.mapper.construction.converter.Converter;
import net.projectmonkey.object.mapper.construction.postprocessor.PostProcessor;
import net.projectmonkey.object.mapper.construction.rule.MappingRule;
import net.projectmonkey.object.mapper.context.Default;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/*
*
* * Copyright 2012 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
/**
* @author Andy Moody
*
* Annotation which allows the user to define how a property or type behaves
* when a specific group is being processed.
*
* N.B. To apply configuration elements across all groups (including the default)
* which do not have explicit configuration elements defined then
* please use the {@link net.projectmonkey.object.mapper.context.All} group.
*
* Group annotations are detected at the relevant locations according to the configured
* PropertyResolver. So, for a field based PropertyResolver the field itself will be checked
* as well as the declared type of the field.
*
* This can give rise to duplicate configurations - e.g. Group membership defined at the field
* level and also on the type the field represents or Group annotations defined on both the accessor
* and mutator methods in a JavaBean based configuration.
*
* Where duplicate configurations are detected ObjectMapper will attempt to merge the configurations
* using the following rules:
*
* If one configuration for a group defines a particular element of the configuration (e.g. converter)
* that the other does not then this will be used.
* If both configurations define an element of the configuration then the first one processed
* takes priority.
* The value for included is only taken from the first configuration processed.
*
* By default configurations are processed in the following orders:
*
* Field based: [field, declared field type]
* JavaBean based: [accessor method, mutator method, declared return type of the accessor]
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
public @interface Group
{
Class> value() default Default.class;
boolean include() default true;
Class extends Converter> converter() default Converter.class;
Class extends MappingRule>[] rules() default {};
Class extends PostProcessor> postProcessor() default PostProcessor.class;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy