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;
30 import org.onap.aaiclient.client.graphinventory.GraphInventoryPluralFragment;
31 import org.onap.aaiclient.client.graphinventory.GraphInventorySingleFragment;
33 public abstract class SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals, SF extends GraphInventorySingleFragment<?>, PF extends GraphInventoryPluralFragment<?>>
34 extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P, SF, PF> {
36 private static final long serialVersionUID = -337701171277616439L;
37 protected static final String relationshipAPI = "/relationship-list/relationship";
38 protected static final String relatedTo = "/related-to";
40 protected SimpleUri(S type, Object... values) {
44 protected SimpleUri(S type, URI uri) {
49 protected SimpleUri(S type, UriBuilder builder, Object... values) {
50 super(type, builder, values);
54 protected SimpleUri(T parentUri, S childType, Object... childValues) {
55 super(parentUri, childType, childValues);
58 protected SimpleUri(SimpleBaseUri<T, T, S> copy) {
63 public T resourceVersion(String version) {
64 this.internalURI = internalURI.replaceQueryParam("resource-version", version);
69 public T relationshipAPI() {
70 this.internalURI = internalURI.path(relationshipAPI);
74 private void writeObject(ObjectOutputStream oos) throws IOException {
75 oos.defaultWriteObject();
76 oos.writeUTF(this.internalURI.toTemplate());
79 private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
80 ois.defaultReadObject();
81 String uri = ois.readUTF();
82 this.setInternalURI(UriBuilder.fromUri(uri));