jp.co.ctc_g.rack.core.model.RackEntity.java Source code

Java tutorial

Introduction

Here is the source code for jp.co.ctc_g.rack.core.model.RackEntity.java

Source

/*
 *  Copyright (c) 2013 ITOCHU Techno-Solutions Corporation.
 *
 *  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 jp.co.ctc_g.rack.core.model;

import java.util.UUID;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.data.mongodb.core.index.Indexed;

/**
 * <p>
 * ????RACK?????
 * </p>
 * @author ITOCHU Techno-Solutions Corporation.
 */
public abstract class RackEntity {

    /**
     * ID
     */
    @Indexed
    private String groupId;

    /**
     * ????
     * @param <T> 
     * @return 
     */
    public abstract <T> T entity();

    /**
     * ??
     */
    public RackEntity() {

        this(UUID.randomUUID().toString());
    }

    /**
     * ID???
     * @param gid ID
     */
    public RackEntity(String gid) {

        this.groupId = gid;
    }

    /**
     * ????
     * @param gid ID
     * @return 
     */
    public RackEntity groupId(String gid) {

        this.groupId = gid;
        return this;
    }

    /**
     * ID????
     * @return ID
     */
    public String getGroupId() {

        return groupId;
    }

    @Override
    public String toString() {

        return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
    }
}