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

com.github.jinahya.openfire.persistence.OfProp Maven / Gradle / Ivy

There is a newer version: 0.1.9
Show newest version
/*
 * Copyright 2017 Jin Kwon <onacit at gmail.com>.
 *
 * 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.
 */
package com.github.jinahya.openfire.persistence;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * An abstract class for {@code Prop} classes.
 *
 * @author Jin Kwon <onacit at gmail.com>
 * @param  subclass type parameter
 */
@XmlTransient
@MappedSuperclass
public abstract class OfProp> extends OfMapped {

    private static final long serialVersionUID = -1750574068804750182L;

    // -------------------------------------------------------------------------
    public static final String COLUMN_NAME_NAME = "name";

    public static final String ATTRIBUTE_VALUE_NAME = "name";

    // -------------------------------------------------------------------------
    public static final String COLUMN_NAME_PROP_VALUE = "propValue";

    public static final String ATTRIBUTE_NAME_PROP_VALUE = "propValue";

    // -------------------------------------------------------------------------
    @Override
    public String toString() {
        return super.toString() + "{"
               + "name=" + name
               + ",propValue=" + propValue
               + "}";
    }

    // -------------------------------------------------------------------- name
    public String getName() {
        return name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    @SuppressWarnings("unchecked")
    public T name(final String name) {
        setName(name);
        return (T) this;
    }

    // --------------------------------------------------------------- propValue
    public String getPropValue() {
        return propValue;
    }

    public void setPropValue(final String propValue) {
        this.propValue = propValue;
    }

    @SuppressWarnings("unchecked")
    public T propValue(final String propValue) {
        setPropValue(propValue);
        return (T) this;
    }

    // -------------------------------------------------------------------------
    @XmlElement(required = true)
    @NotNull
    @Id
    @Column(name = COLUMN_NAME_NAME, nullable = false)
    @NamedAttribute(ATTRIBUTE_VALUE_NAME)
    private String name;

    @XmlElement(required = true)
    @NotNull
    @Column(name = COLUMN_NAME_PROP_VALUE, nullable = false)
    @NamedAttribute(ATTRIBUTE_NAME_PROP_VALUE)
    private String propValue;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy