Java tutorial
/******************************************************************************* * Copyright 2014 Barcelona Supercomputing Center (BSC) * * 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 com.servioticy.datamodel.serviceobject; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import java.util.LinkedHashMap; /** * @author ?lvaro Villalba Navarro <alvaro.villalba@bsc.es> * */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public class SOStream { private LinkedHashMap<String, SOChannel> channels; private String description; public LinkedHashMap<String, SOChannel> getChannels() { return channels; } public void setChannels(LinkedHashMap<String, SOChannel> channels) { this.channels = channels; } @JsonGetter("channels") public LinkedHashMap<String, SOChannel> getNotNullOrEmptyChannels() throws JsonGenerationException { if (channels == null || channels.size() < 1) { throw new JsonGenerationException("At least one channel is required"); } return getChannels(); } @JsonSetter("channels") public void setNotNullOrEmptyChannels(LinkedHashMap<String, SOChannel> channels) throws JsonMappingException { if (channels == null || channels.size() < 1) { throw new JsonMappingException("At least one channel is required"); } setChannels(channels); } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }