-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementations for model objects of Devfile
Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
- Loading branch information
1 parent
d3d1f22
commit 4957200
Showing
13 changed files
with
1,391 additions
and
72 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
55 changes: 0 additions & 55 deletions
55
...-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/DevfileImpl.java
This file was deleted.
Oops, something went wrong.
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
111 changes: 111 additions & 0 deletions
111
...ace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ActionImpl.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,111 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.workspace.server.model.impl.devfile; | ||
|
||
import java.util.Objects; | ||
import org.eclipse.che.api.core.model.workspace.devfile.Action; | ||
|
||
/** @author Sergii Leshchenko */ | ||
public class ActionImpl implements Action { | ||
|
||
private String type; | ||
private String component; | ||
private String command; | ||
private String workdir; | ||
|
||
public ActionImpl() {} | ||
|
||
public ActionImpl(String type, String component, String command, String workdir) { | ||
this.type = type; | ||
this.component = component; | ||
this.command = command; | ||
this.workdir = workdir; | ||
} | ||
|
||
public ActionImpl(Action action) { | ||
this(action.getType(), action.getComponent(), action.getCommand(), action.getWorkdir()); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public String getComponent() { | ||
return component; | ||
} | ||
|
||
public void setComponent(String component) { | ||
this.component = component; | ||
} | ||
|
||
@Override | ||
public String getCommand() { | ||
return command; | ||
} | ||
|
||
public void setCommand(String command) { | ||
this.command = command; | ||
} | ||
|
||
@Override | ||
public String getWorkdir() { | ||
return workdir; | ||
} | ||
|
||
public void setWorkdir(String workdir) { | ||
this.workdir = workdir; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof ActionImpl)) { | ||
return false; | ||
} | ||
ActionImpl action = (ActionImpl) o; | ||
return Objects.equals(getType(), action.getType()) | ||
&& Objects.equals(getComponent(), action.getComponent()) | ||
&& Objects.equals(getCommand(), action.getCommand()) | ||
&& Objects.equals(getWorkdir(), action.getWorkdir()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getType(), getComponent(), getCommand(), getWorkdir()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ActionImpl{" | ||
+ "type='" | ||
+ type | ||
+ '\'' | ||
+ ", component='" | ||
+ component | ||
+ '\'' | ||
+ ", command='" | ||
+ command | ||
+ '\'' | ||
+ ", workdir='" | ||
+ workdir | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
...ce/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/CommandImpl.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,111 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.workspace.server.model.impl.devfile; | ||
|
||
import static java.util.stream.Collectors.toCollection; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import org.eclipse.che.api.core.model.workspace.devfile.Action; | ||
import org.eclipse.che.api.core.model.workspace.devfile.Command; | ||
|
||
/** @author Sergii Leshchenko */ | ||
public class CommandImpl implements Command { | ||
|
||
private String name; | ||
private List<ActionImpl> actions; | ||
private Map<String, String> attributes; | ||
|
||
public CommandImpl() {} | ||
|
||
public CommandImpl(String name, List<? extends Action> actions, Map<String, String> attributes) { | ||
this.name = name; | ||
if (actions != null) { | ||
this.actions = actions.stream().map(ActionImpl::new).collect(toCollection(ArrayList::new)); | ||
} | ||
if (attributes != null) { | ||
this.attributes = new HashMap<>(attributes); | ||
} | ||
} | ||
|
||
public CommandImpl(Command command) { | ||
this(command.getName(), command.getActions(), command.getAttributes()); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public List<ActionImpl> getActions() { | ||
if (actions == null) { | ||
actions = new ArrayList<>(); | ||
} | ||
return actions; | ||
} | ||
|
||
public void setActions(List<ActionImpl> actions) { | ||
this.actions = actions; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getAttributes() { | ||
if (attributes == null) { | ||
attributes = new HashMap<>(); | ||
} | ||
return attributes; | ||
} | ||
|
||
public void setAttributes(Map<String, String> attributes) { | ||
this.attributes = attributes; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof CommandImpl)) { | ||
return false; | ||
} | ||
CommandImpl command = (CommandImpl) o; | ||
return Objects.equals(getName(), command.getName()) | ||
&& Objects.equals(getActions(), command.getActions()) | ||
&& Objects.equals(getAttributes(), command.getAttributes()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getName(), getActions(), getAttributes()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CommandImpl{" | ||
+ "name='" | ||
+ name | ||
+ '\'' | ||
+ ", actions=" | ||
+ actions | ||
+ ", attributes=" | ||
+ attributes | ||
+ '}'; | ||
} | ||
} |
Oops, something went wrong.