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

org.eclipse.jnosql.lite.mapping.entities.CarPlateFieldMetaData Maven / Gradle / Ivy

/*
 *  Copyright (c) 2023 Otávio Santana and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   Otavio Santana
 */
package org.eclipse.jnosql.lite.mapping.entities;

import java.lang.annotation.Annotation;

import org.eclipse.jnosql.communication.Value;
import org.eclipse.jnosql.mapping.AttributeConverter;
import org.eclipse.jnosql.mapping.metadata.FieldMetadata;
import org.eclipse.jnosql.mapping.metadata.MappingType;

import javax.annotation.processing.Generated;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

@Generated(value= "JNoSQL Lite FieldMetadata Generator", date = "2023-12-02T14:20:40.734333232")
public final class CarPlateFieldMetaData implements FieldMetadata {

    private final AttributeConverter converter;

    private final Class> typeConverter;

    private final Map, String> valueByAnnotation;

    public CarPlateFieldMetaData() {
        this.converter = new org.eclipse.jnosql.lite.mapping.entities.PlateConverter();
        this.typeConverter = org.eclipse.jnosql.lite.mapping.entities.PlateConverter.class;
         this.valueByAnnotation = java.util.Collections.emptyMap();
    }

    @Override
    public boolean isId() {
        return true;
    }

    @Override
    public  Optional value(Class type) {
        Objects.requireNonNull(type, "type is required");
        return Optional.ofNullable(this.valueByAnnotation.get(type));
    }

    @Override
    public > Optional> converter() {
        return Optional.ofNullable((Class) typeConverter);
    }

    @Override
    public > Optional newConverter() {
        return (Optional) Optional.ofNullable(converter);
    }

    @Override
    public MappingType mappingType() {
        return MappingType.DEFAULT;
    }

    @Override
    public String name() {
        return "_id";
    }

    @Override
    public String fieldName() {
        return "plate";
    }

    @Override
    public Object value(Value value) {
        Objects.requireNonNull(value, "value is required");
        return value.get(org.eclipse.jnosql.lite.mapping.entities.Plate.class);
    }

    @Override
    public void write(Object bean, Object value) {
        ((Car) bean).setPlate((org.eclipse.jnosql.lite.mapping.entities.Plate)value);
    }

    @Override
    public Object read(Object bean) {
        return ((Car) bean).getPlate();
    }

    @Override
    public Class type() {
        return org.eclipse.jnosql.lite.mapping.entities.Plate.class;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy