001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.krad.data; 017 018import java.io.Serializable; 019 020import javax.persistence.Version; 021 022import org.apache.commons.lang.StringUtils; 023import org.kuali.rice.core.api.mo.common.GloballyUnique; 024 025 026/** 027 * CopyOption is used when calling the {@link DataObjectService#copyInstance(Object)} method to adjust the behavior of 028 * the method. 029 * 030 * See the constants defined within the class for the available options and descriptions. 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034public class CopyOption implements Serializable { 035 private static final long serialVersionUID = 1L; 036 037 /** 038 * Specify that the PK fields on the object must be cleared as part of the copy operation. 039 */ 040 public static CopyOption RESET_PK_FIELDS = new CopyOption("org.kuali.rice.krad.data.RESET_PK_FIELDS"); 041 042 /** 043 * Specify that the {@link Version} annotated field should be cleared if present on the copied object. 044 */ 045 public static CopyOption RESET_VERSION_NUMBER = new CopyOption("org.kuali.rice.krad.data.RESET_VERSION_NUMBER"); 046 047 /** 048 * Specify that the {@literal <tt>objectId</tt>} field (see {@link GloballyUnique}) should be cleared on the copied 049 * object and all children. 050 */ 051 public static CopyOption RESET_OBJECT_ID = new CopyOption("org.kuali.rice.krad.data.RESET_OBJECT_ID"); 052 053 private final String optionId; 054 055 /** 056 * Sets the option Id 057 * 058 * @param optionId 059 * cannot be null or blank. 060 */ 061 public CopyOption(String optionId) { 062 if (StringUtils.isBlank(optionId)) { 063 throw new IllegalArgumentException("optionId must not be a null or blank value"); 064 } 065 this.optionId = optionId; 066 } 067 068 /** 069 * Gets the option id. 070 * 071 * @return not null or blank. 072 */ 073 public String getOptionId() { 074 return this.optionId; 075 } 076 077 @Override 078 public String toString() { 079 return optionId; 080 } 081}