-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
czfdcn
committed
Sep 8, 2023
1 parent
92eb9c9
commit e48f772
Showing
8 changed files
with
186 additions
and
12 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/org/eclipse/uprotocol/uri/datamodel/LongUri.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2023 General Motors GTO LLC | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.eclipse.uprotocol.uri.datamodel; | ||
|
||
import org.eclipse.uprotocol.uri.factory.UriFactory; | ||
|
||
/** | ||
* Long Format URI | ||
*/ | ||
public class LongUri extends UriFormat<String> { | ||
|
||
public LongUri(UUri uri) { | ||
super (UriFactory.buildUProtocolUri(uri), uri); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return uProtocolUri.isEmpty(); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/eclipse/uprotocol/uri/datamodel/MicroUri.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2023 General Motors GTO LLC | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.eclipse.uprotocol.uri.datamodel; | ||
|
||
import org.eclipse.uprotocol.uri.factory.UriFactory; | ||
|
||
/** | ||
* Micro Format uProtocol URI. | ||
*/ | ||
public class MicroUri extends UriFormat<byte[]>{ | ||
|
||
public MicroUri(UUri uri) { | ||
super(UriFactory.buildUProtocolMicroUri(uri), uri); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return uProtocolUri.length == 0; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/org/eclipse/uprotocol/uri/datamodel/ShortUri.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2023 General Motors GTO LLC | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.eclipse.uprotocol.uri.datamodel; | ||
|
||
import org.eclipse.uprotocol.uri.factory.UriFactory; | ||
|
||
public class ShortUri extends UriFormat<String> { | ||
|
||
public ShortUri(UUri uri) { | ||
super(UriFactory.buildUProtocolShortUri(uri), uri); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return uProtocolUri.isEmpty(); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/org/eclipse/uprotocol/uri/datamodel/UriFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.eclipse.uprotocol.uri.datamodel; | ||
|
||
/** | ||
* UriFormat is the interface that represents either Long, Short, or micro formats of a uProtocol Uri. | ||
* UriFormat is passed to the transports such that a transport can fix what format they expect to use. | ||
* | ||
* @param <T> The type used for the uProtocol Uri, long and short use String while micro is byte[] | ||
*/ | ||
public abstract class UriFormat<T> { | ||
protected final T uProtocolUri; | ||
private final UUri uuri; | ||
|
||
/** | ||
* Constructor for UriFormat called by the child classes (Short, Long, Micro) | ||
* @param uProtocolUri Format specific generated uProtocol URI | ||
* @param uuri UUri data object | ||
*/ | ||
protected UriFormat(T uProtocolUri, UUri uuri) { | ||
this.uProtocolUri = uProtocolUri; | ||
this.uuri = uuri; | ||
} | ||
|
||
/** | ||
* Return the uProtocol URI in the correct expected format | ||
* @return uProtocol URI | ||
*/ | ||
public T uProtocolUri() { | ||
return uProtocolUri; | ||
} | ||
|
||
/** | ||
* Obtain the UUri that was used to build the Uri Format | ||
* This method might be used if we want to convert from one format to another | ||
* @return UUri data object | ||
*/ | ||
public UUri uuri() { | ||
return uuri; | ||
} | ||
|
||
/** | ||
* Check if the UProtocolUri is empty. An empty Uri means that we were not able to | ||
* build it from the UUri. | ||
* @return true if empty, false otherwise | ||
*/ | ||
abstract boolean isEmpty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters