1 /* 2 * Copyright 2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.admin.domain.model; 17 18 import java.io.Serializable; 19 import java.util.List; 20 21 import de.smartics.util.lang.Arg; 22 23 /** 24 * The aggregate of services provided by the API. 25 */ 26 public final class ApiServices implements Serializable 27 { 28 // ********************************* Fields ********************************* 29 30 // --- constants ------------------------------------------------------------ 31 32 /** 33 * The class version identifier. 34 * <p> 35 * The value of this constant is {@value}. 36 * </p> 37 */ 38 private static final long serialVersionUID = 1L; 39 40 // --- members -------------------------------------------------------------- 41 42 /** 43 * The list of services provided. 44 * 45 * @serial 46 */ 47 private final List<ServiceDescriptor> services; 48 49 // ****************************** Initializer ******************************* 50 51 // ****************************** Constructors ****************************** 52 53 /** 54 * Default constructor. 55 * 56 * @param services the list of services provided. 57 * @throws NullPointerException if {@code services} is <code>null</code>. 58 */ 59 public ApiServices(final List<ServiceDescriptor> services) 60 throws NullPointerException 61 { 62 this.services = Arg.checkNotNull("services", services); 63 } 64 65 // ****************************** Inner Classes ***************************** 66 67 /** 68 * The descriptor of the service that is part of the API. 69 */ 70 public static final class ServiceDescriptor implements Serializable 71 { 72 // ******************************** Fields ******************************** 73 74 // --- constants ---------------------------------------------------------- 75 76 /** 77 * The class version identifier. 78 * <p> 79 * The value of this constant is {@value}. 80 * </p> 81 */ 82 private static final long serialVersionUID = 1L; 83 84 // --- members ------------------------------------------------------------ 85 86 /** 87 * The identifier of the service. It is used as a lookup key to attach 88 * metadata information. 89 * 90 * @serial 91 */ 92 private final String id; 93 94 /** 95 * The resource that implements the service. 96 * 97 * @serial 98 */ 99 private final Class<?> resourceType; 100 101 // ***************************** Initializer ****************************** 102 103 // ***************************** Constructors ***************************** 104 105 /** 106 * Default constructor. 107 * 108 * @param id the identifier of the service. It is used as a lookup key to 109 * attach metadata information. 110 * @param resourceType the resource that implements the service. 111 */ 112 public ServiceDescriptor(final String id, final Class<?> resourceType) 113 { 114 this.id = id; 115 this.resourceType = resourceType; 116 } 117 118 // ***************************** Inner Classes **************************** 119 120 // ******************************** Methods ******************************* 121 122 // --- init --------------------------------------------------------------- 123 124 // --- get&set ------------------------------------------------------------ 125 126 /** 127 * Returns the identifier of the service. It is used as a lookup key to 128 * attach metadata information. 129 * 130 * @return the identifier of the service. 131 */ 132 public String getId() 133 { 134 return id; 135 } 136 137 /** 138 * Returns the resource that implements the service. 139 * 140 * @return the resource that implements the service. 141 */ 142 public Class<?> getResourceType() 143 { 144 return resourceType; 145 } 146 147 // --- business ----------------------------------------------------------- 148 149 // --- object basics ------------------------------------------------------ 150 151 @Override 152 public String toString() 153 { 154 return id + ": " + resourceType.getName(); 155 } 156 157 } 158 159 // ********************************* Methods ******************************** 160 161 // --- init ----------------------------------------------------------------- 162 163 // --- get&set -------------------------------------------------------------- 164 165 /** 166 * Returns the list of services provided. 167 * 168 * @return the list of services provided. 169 */ 170 public List<ServiceDescriptor> getServices() 171 { 172 return services; 173 } 174 175 // --- business ------------------------------------------------------------- 176 177 // --- object basics -------------------------------------------------------- 178 179 }