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;
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 SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals>
32 extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P> {
34 private static final long serialVersionUID = -337701171277616439L;
35 protected static final String relationshipAPI = "/relationship-list/relationship";
36 protected static final String relatedTo = "/related-to";
38 protected SimpleUri(S type, Object... values) {
42 protected SimpleUri(S type, URI uri) {
47 protected SimpleUri(S type, UriBuilder builder, Object... values) {
48 super(type, builder, values);
52 protected SimpleUri(T parentUri, S childType, Object... childValues) {
53 super(parentUri, childType, childValues);
56 protected SimpleUri(SimpleBaseUri<T, T, S> copy) {
61 public T resourceVersion(String version) {
62 this.internalURI = internalURI.replaceQueryParam("resource-version", version);
67 public T relationshipAPI() {
68 this.internalURI = internalURI.path(relationshipAPI);
72 private void writeObject(ObjectOutputStream oos) throws IOException {
73 oos.defaultWriteObject();
74 oos.writeUTF(this.internalURI.toTemplate());
77 private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
78 ois.defaultReadObject();
79 String uri = ois.readUTF();
80 this.setInternalURI(UriBuilder.fromUri(uri));