All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javersion.object.mapping.SimpleValueMapping Maven / Gradle / Ivy

There is a newer version: 0.15.3
Show newest version
package org.javersion.object.mapping;

import javax.annotation.Nullable;

import org.javersion.object.DescribeContext;
import org.javersion.object.TypeContext;
import org.javersion.object.types.ValueType;
import org.javersion.path.PropertyPath;
import org.javersion.reflect.TypeDescriptor;
import org.javersion.util.Check;

public class SimpleValueMapping implements TypeMapping {

    public final Class type;

    public final ValueType valueType;

    public SimpleValueMapping(Class type, ValueType valueType) {
        this.type = Check.notNull(type, "type");
        this.valueType = Check.notNull(valueType, "valueType");
    }

    @Override
    public boolean applies(PropertyPath path, TypeContext typeContext) {
        TypeDescriptor typeDescriptor = typeContext.type;
        return typeDescriptor.getRawType().equals(type);
    }

    @Override
    public ValueType describe(@Nullable PropertyPath path, TypeDescriptor type, DescribeContext context) {
        return valueType;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy