2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aaiclient.client.graphinventory.entities.uri;
23 import java.io.IOException;
24 import java.io.ObjectInputStream;
25 import java.io.ObjectOutputStream;
26 import java.io.Serializable;
27 import javax.ws.rs.core.UriBuilder;
28 import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals;
29 import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
31 public abstract class SimplePluralUri<T extends GraphInventoryPluralResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PT extends GraphInventoryObjectPlurals, OT extends GraphInventoryObjectType>
32 extends SimpleBaseUri<T, Parent, PT> implements GraphInventoryPluralResourceUri<T, PT>, Serializable {
34 private static final long serialVersionUID = -337701171277616439L;
36 protected final PT pluralType;
38 protected SimplePluralUri(PT type, UriBuilder builder, Object... values) {
39 super(type, builder, values);
40 this.pluralType = type;
43 protected SimplePluralUri(PT type) {
44 super(type, new Object[0]);
45 this.pluralType = type;
48 protected SimplePluralUri(PT type, Object... values) {
50 this.pluralType = type;
53 protected SimplePluralUri(Parent parentUri, PT childType) {
54 super(parentUri, childType, new Object[0]);
55 this.pluralType = childType;
58 public SimplePluralUri(SimplePluralUri<T, Parent, PT, OT> copy) {
60 this.pluralType = copy.pluralType;
63 protected void setInternalURI(UriBuilder builder) {
64 this.internalURI = builder;
67 private void writeObject(ObjectOutputStream oos) throws IOException {
68 oos.defaultWriteObject();
69 oos.writeUTF(this.internalURI.toTemplate());
72 private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
73 ois.defaultReadObject();
74 String uri = ois.readUTF();
75 this.setInternalURI(UriBuilder.fromUri(uri));