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

org.glassfish.jaxb.runtime.v2.model.impl.FieldPropertySeed Maven / Gradle / Ivy

There is a newer version: 4.0.5
Show newest version
/*
 * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.glassfish.jaxb.runtime.v2.model.impl;

import org.glassfish.jaxb.core.v2.model.annotation.Locatable;
import org.glassfish.jaxb.core.v2.model.core.PropertyInfo;
import org.glassfish.jaxb.core.v2.runtime.Location;

import java.lang.annotation.Annotation;

/**
 * {@link PropertyInfo} implementation backed by a field.
 */
class FieldPropertySeed implements
        PropertySeed {

    protected final FieldT field;
    private ClassInfoImpl parent;

    FieldPropertySeed(ClassInfoImpl classInfo, FieldT field) {
        this.parent = classInfo;
        this.field = field;
    }

    @Override
    public  A readAnnotation(Class a) {
        return parent.reader().getFieldAnnotation(a, field,this);
    }

    @Override
    public boolean hasAnnotation(Class annotationType) {
        return parent.reader().hasFieldAnnotation(annotationType,field);
    }

    @Override
    public String getName() {
        // according to the spec team, the BeanIntrospector.decapitalize does not apply
        // to the fields. Don't call Introspector.decapitalize
        return parent.nav().getFieldName(field);
    }

    @Override
    public TypeT getRawType() {
        return parent.nav().getFieldType(field);
    }

    /**
     * Use the enclosing class as the upsream {@link Location}.
     */
    @Override
    public Locatable getUpstream() {
        return parent;
    }

    @Override
    public Location getLocation() {
        return parent.nav().getFieldLocation(field);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy