Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing HasIdInIdOrNameField and HasName
Signed-off-by: Oliver Kopp <kopp.dev@gmail.com>
- Loading branch information
Showing
8 changed files
with
72 additions
and
67 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
...winery.model.tosca/src/main/java/org/eclipse/winery/model/tosca/HasIdInIdOrNameField.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,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 University of Stuttgart. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and the Apache License 2.0 which both accompany this distribution, | ||
* and are available at http://www.eclipse.org/legal/epl-v10.html | ||
* and http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Contributors: | ||
* Oliver Kopp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.winery.model.tosca; | ||
|
||
public interface HasIdInIdOrNameField { | ||
|
||
/** | ||
* Returns the id | ||
*/ | ||
default String getId() { | ||
if (this instanceof HasId) { | ||
return ((HasId) this).getId(); | ||
} else { | ||
return ((HasName) this).getName(); | ||
} | ||
} | ||
|
||
/** | ||
* Sets the id using the given string. | ||
* In case the class implements HasId, the id is set using HasId.setId. | ||
* Otherwise, the name attribute is set | ||
* | ||
* @param id the id to set | ||
*/ | ||
default void setId(String id) { | ||
if (this instanceof HasId) { | ||
((HasId) this).setId(id); | ||
} else { | ||
((HasName) this).setName(id); | ||
} | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
org.eclipse.winery.model.tosca/src/main/java/org/eclipse/winery/model/tosca/HasName.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,20 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 University of Stuttgart. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and the Apache License 2.0 which both accompany this distribution, | ||
* and are available at http://www.eclipse.org/legal/epl-v10.html | ||
* and http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Contributors: | ||
* Oliver Kopp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.winery.model.tosca; | ||
|
||
public interface HasName extends HasIdInIdOrNameField { | ||
|
||
String getName(); | ||
|
||
void setName(String value); | ||
|
||
} |
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
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