001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.api.document.attribute; 017 018 import javax.xml.bind.annotation.XmlAccessType; 019 import javax.xml.bind.annotation.XmlAccessorType; 020 import javax.xml.bind.annotation.XmlElement; 021 import javax.xml.bind.annotation.XmlRootElement; 022 import javax.xml.bind.annotation.XmlType; 023 import java.math.BigInteger; 024 025 /** 026 * A document attribute which contains integer data. Construct instances of {@code DocumentAttributeInteger} using 027 * it's builder or the {@link DocumentAttributeFactory}. 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031 @XmlRootElement(name = DocumentAttributeInteger.Constants.ROOT_ELEMENT_NAME) 032 @XmlAccessorType(XmlAccessType.NONE) 033 @XmlType(name = DocumentAttributeInteger.Constants.TYPE_NAME, propOrder = { 034 DocumentAttributeInteger.Elements.VALUE 035 }) 036 public final class DocumentAttributeInteger extends DocumentAttribute { 037 038 @XmlElement(name = Elements.VALUE, required = false) 039 private final BigInteger value; 040 041 @SuppressWarnings("unused") 042 private DocumentAttributeInteger() { 043 this.value = null; 044 } 045 046 private DocumentAttributeInteger(Builder builder) { 047 super(builder.getName()); 048 this.value = builder.getValue(); 049 } 050 051 @Override 052 public BigInteger getValue() { 053 return value; 054 } 055 056 @Override 057 public DocumentAttributeDataType getDataType() { 058 return DocumentAttributeDataType.INTEGER; 059 } 060 061 /** 062 * A builder implementation which allows for construction of a {@code DocumentAttributeInteger}. 063 */ 064 public static final class Builder extends AbstractBuilder<BigInteger> { 065 066 private Builder(String name) { 067 super(name); 068 } 069 070 /** 071 * Create a builder for the document attribute using the given attribute name. 072 * 073 * @param name the name of the document attribute which should be built by this builder, should never be a 074 * null or blank value 075 * @return a builder instance initialized with the given attribute name 076 */ 077 public static Builder create(String name) { 078 return new Builder(name); 079 } 080 081 @Override 082 public DocumentAttributeDataType getDataType() { 083 return DocumentAttributeDataType.INTEGER; 084 } 085 086 @Override 087 public DocumentAttributeInteger build() { 088 return new DocumentAttributeInteger(this); 089 } 090 091 } 092 093 /** 094 * Defines some internal constants used on this class. 095 */ 096 static class Constants { 097 final static String ROOT_ELEMENT_NAME = "documentAttributeInteger"; 098 final static String TYPE_NAME = "DocumentAttributeIntegerType"; 099 } 100 101 /** 102 * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML. 103 */ 104 static class Elements { 105 final static String VALUE = "value"; 106 } 107 108 }