All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.simpleflatmapper.reflect.meta.ConstructorPropertyMeta Maven / Gradle / Ivy
package org.simpleflatmapper.reflect.meta;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.InstantiatorDefinition;
import org.simpleflatmapper.reflect.ScoredSetter;
import org.simpleflatmapper.reflect.Parameter;
import org.simpleflatmapper.reflect.ReflectionService;
import org.simpleflatmapper.reflect.ScoredGetter;
import org.simpleflatmapper.reflect.Setter;
import java.lang.reflect.Type;
public class ConstructorPropertyMeta extends PropertyMeta {
private final ScoredSetter scoredSetter;
private final ScoredGetter scoredGetter;
private final Parameter parameter;
private final InstantiatorDefinition instantiatorDefinition;
private final Object[] defineProperties;
public ConstructorPropertyMeta(String name,
Type ownerType,
ReflectionService reflectService,
Parameter parameter,
InstantiatorDefinition instantiatorDefinition,
Object[] defineProperties) {
this(name, ownerType, reflectService, parameter, ScoredGetter.nullGetter(), ScoredSetter.nullSetter(), instantiatorDefinition, defineProperties);
}
public ConstructorPropertyMeta(String name,
Type ownerType,
ReflectionService reflectService,
Parameter parameter,
ScoredGetter scoredGetter,
ScoredSetter scoredSetter,
InstantiatorDefinition instantiatorDefinition, Object[] defineProperties) {
super(name, ownerType, reflectService);
this.parameter = parameter;
this.scoredGetter = scoredGetter;
this.scoredSetter = scoredSetter;
this.instantiatorDefinition = instantiatorDefinition;
this.defineProperties = defineProperties;
}
@Override
public Setter getSetter() {
return scoredSetter.getSetter();
}
@Override
public Getter getGetter() {
return scoredGetter.getGetter();
}
public ConstructorPropertyMeta defineProperties(Object[] defineProperties) {
if (defineProperties != null) {
return new ConstructorPropertyMeta(getName(), getOwnerType(), reflectService, parameter, scoredGetter, scoredSetter, instantiatorDefinition, ObjectPropertyMeta.concatenate(this.defineProperties, defineProperties));
} else {
return this;
}
}
public ConstructorPropertyMeta getter(ScoredGetter getter) {
if (getter.isBetterThan(this.scoredGetter)) {
return new ConstructorPropertyMeta(getName(), getOwnerType(), reflectService, parameter, getter, scoredSetter, instantiatorDefinition, defineProperties);
} else {
return this;
}
}
public ConstructorPropertyMeta setter(ScoredSetter setter) {
if (setter.isBetterThan(this.scoredSetter)) {
return new ConstructorPropertyMeta(getName(), getOwnerType(), reflectService, parameter, scoredGetter, setter, instantiatorDefinition, defineProperties);
} else {
return this;
}
}
@Override
public Type getPropertyType() {
return parameter.getGenericType();
}
public Parameter getParameter() {
return parameter;
}
public boolean isConstructorProperty() {
return true;
}
@Override
public Object[] getDefinedProperties() {
return defineProperties;
}
@Override
public String getPath() {
return getName();
}
@Override
public String toString() {
return "ConstructorPropertyMeta{" +
"owner=" + getOwnerType() +
", constructorParameter=" + parameter +
'}';
}
public ConstructorPropertyMeta withReflectionService(ReflectionService reflectionService) {
return new ConstructorPropertyMeta(getName(), getOwnerType(), reflectionService, parameter, scoredGetter, scoredSetter, instantiatorDefinition, defineProperties);
}
@Override
public PropertyMeta toNonMapped() {
throw new UnsupportedOperationException();
}
}