Java tutorial
/* * Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security). * * 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 egovframework.rte.itl.integration.metadata; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; import org.springframework.util.StringUtils; import egovframework.rte.itl.integration.util.Validatable; /** * ?? '' ? * <p> * <b>NOTE:</b> ? ?? '' * class?. * @author ? * @since 2009.06.01 * @version 1.0 * @see <pre> * == ?(Modification Information) == * * ? ? * ------- -------- --------------------------- * 2009.06.01 ? ? * * </pre> */ public class OrganizationDefinition implements Validatable { /** ID */ private String id; /** */ private String name; /** ? */ private Map<String, SystemDefinition> systems = new HashMap<String, SystemDefinition>(); /** valid */ private boolean valid = false; /** statucChanged flag */ private AtomicBoolean statusChanged = new AtomicBoolean(false); /** * Default Constructor */ public OrganizationDefinition() { super(); } /** * Constructor * @param id * ID * @param name * */ public OrganizationDefinition(String id, String name) { super(); this.id = id; this.name = name; this.statusChanged.set(true); } /** * Constructor * @param id * ID * @param name * * @param systems * ? */ public OrganizationDefinition(String id, String name, Map<String, SystemDefinition> systems) { super(); this.id = id; this.name = name; this.systems = systems; this.statusChanged.set(true); } /** * @return the id */ public String getId() { return id; } /** * @param id * the id to set */ public void setId(String id) { this.id = id; this.statusChanged.set(true); } /** * @return the name */ public String getName() { return name; } /** * @param name * the name to set */ public void setName(String name) { this.name = name; this.statusChanged.set(true); } /** * @return the systems */ public Map<String, SystemDefinition> getSystems() { return systems; } /** * @param systems * the systems to set */ public void setSystems(Map<String, SystemDefinition> systems) { this.systems = systems; this.statusChanged.set(true); } /** * SystemDefinition? ?. * @param systemId * systemId * @return SystemDefinition */ public SystemDefinition getSystemDefinition(String systemId) { return systems.get(systemId); } public boolean isValid() { if (statusChanged.getAndSet(false)) { valid = (StringUtils.hasText(id) && StringUtils.hasText(name) && systems != null); if (systems != null) { for (SystemDefinition system : systems.values()) { valid = valid && system.isValid(); } } } return valid; } @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this.getClass().getName()).append(" {").append("\n\tid = ").append(StringUtils.quote(id)) .append("\n\tname = ").append(StringUtils.quote(name)); if (systems == null) { sb.append("\n\tsystems = null"); } else { sb.append("\n\tsystems = {"); for (Entry<String, SystemDefinition> entry : systems.entrySet()) { sb.append("\n\t\t<key = ").append(StringUtils.quote(entry.getKey())).append(", value = ") .append(entry.getValue() == null ? "" : "\n").append(entry.getValue()).append(">"); } sb.append("\n\t}"); } sb.append("\n}"); return sb.toString(); } }