001/* 002 * Copyright 2020 Anyware Services 003 * 004 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 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.ametys.plugins.repository.data.holder.values; 017 018import java.util.List; 019 020import org.ametys.plugins.repository.data.DataComment; 021import org.ametys.plugins.repository.data.external.ExternalizableDataProvider.ExternalizableDataStatus; 022 023/** 024 * Wrapper for a synchronizable value 025 * Contains the value itself and indicates if it is the external value 026 */ 027public class SynchronizableValue 028{ 029 private Object _value; 030 private Object _externalValue; 031 private ExternalizableDataStatus _externalizableDataStatus; 032 private List<DataComment> _comments; 033 private Mode _mode = Mode.REPLACE; 034 035 /** 036 * The value write mode. 037 */ 038 public static enum Mode 039 { 040 /** The value will replace existing values */ 041 REPLACE, 042 /** The value will be appended to existing values */ 043 APPEND, 044 /** The value will be removed if found among existing values */ 045 REMOVE 046 } 047 048 /** 049 * Constructor. 050 * @param value the actual value. 051 */ 052 public SynchronizableValue(Object value) 053 { 054 _value = value; 055 } 056 057 /** 058 * Retrieves the synchronizable value 059 * @return the synchronizable value 060 */ 061 public Object getValue() 062 { 063 return _value; 064 } 065 066 /** 067 * Sets the synchronizable value 068 * @param value the synchronizable value to set 069 */ 070 public void setValue(Object value) 071 { 072 _value = value; 073 } 074 075 /** 076 * Retrieves the external value 077 * @return the external value 078 */ 079 public Object getExternalValue() 080 { 081 return _externalValue; 082 } 083 084 /** 085 * Sets the external value 086 * @param externalValue the external value to set 087 */ 088 public void setExternalValue(Object externalValue) 089 { 090 _externalValue = externalValue; 091 } 092 093 /** 094 * Retrieves the externalizable status of the value 095 * @return the externalizable status of the value 096 */ 097 public ExternalizableDataStatus getExternalizableStatus() 098 { 099 return _externalizableDataStatus; 100 } 101 102 /** 103 * Sets the externalizable status of the value 104 * If not set, the status of the value won't be updated 105 * @param externalizableDataStatus the status to set 106 */ 107 public void setExternalizableStatus(ExternalizableDataStatus externalizableDataStatus) 108 { 109 _externalizableDataStatus = externalizableDataStatus; 110 } 111 112 /** 113 * Retrieves the comments associated with the value 114 * @return the comments associated with the value 115 */ 116 public List<DataComment> getComments() 117 { 118 return _comments; 119 } 120 121 /** 122 * Set the comments associated to the value 123 * @param comments the comment 124 */ 125 public void setComments(List<DataComment> comments) 126 { 127 _comments = comments; 128 } 129 130 /** 131 * Retrieves the write mode for the value 132 * @return the write mode for the value 133 */ 134 public Mode getMode() 135 { 136 return _mode; 137 } 138 139 /** 140 * Set the write mode for the value 141 * @param mode the write mode 142 */ 143 public void setMode(Mode mode) 144 { 145 _mode = mode; 146 } 147}