oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataSequenceGenerator Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* glassfish/bootstrap/legal/CDDLv1.0.txt or
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*/
// Copyright (c) 1998, 2007, Oracle. All rights reserved.
package oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing;
import javax.persistence.SequenceGenerator;
/**
* A wrapper class to the MetadataSequenceGenerator that holds onto a
* @SequenceGenerator for its metadata values.
*
* @author Guy Pelletier
* @since TopLink EJB 3.0 Reference Implementation
*/
public class MetadataSequenceGenerator extends MetadataGenerator {
private SequenceGenerator m_sequenceGenerator;
/**
* INTERNAL:
*/
protected MetadataSequenceGenerator(String entityClassName) {
super(entityClassName);
}
/**
* INTERNAL:
*/
public MetadataSequenceGenerator(SequenceGenerator sequenceGenerator, String entityClassName) {
super(entityClassName);
m_sequenceGenerator = sequenceGenerator;
}
/**
* INTERNAL:
*/
public boolean equals(Object objectToCompare) {
if (objectToCompare instanceof MetadataSequenceGenerator) {
MetadataSequenceGenerator generator = (MetadataSequenceGenerator) objectToCompare;
if (!generator.getName().equals(getName())) {
return false;
}
if (generator.getInitialValue() != getInitialValue()) {
return false;
}
if (generator.getAllocationSize() != getAllocationSize()) {
return false;
}
return generator.getSequenceName().equals(getSequenceName());
}
return false;
}
/**
* INTERNAL:
*/
public int getAllocationSize() {
return m_sequenceGenerator.allocationSize();
}
/**
* INTERNAL:
*/
public int getInitialValue() {
return m_sequenceGenerator.initialValue();
}
/**
* INTERNAL:
*/
public String getName() {
return m_sequenceGenerator.name();
}
/**
* INTERNAL:
*/
public String getSequenceName() {
return m_sequenceGenerator.sequenceName();
}
}