1 /*******************************************************************************
2 * Copyright (c) 2017 Politecnico di Torino and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *******************************************************************************/
10 package it.polito.escape.verify.model;
12 import java.util.HashMap;
13 import java.util.HashSet;
17 import javax.xml.bind.annotation.XmlRootElement;
18 import javax.xml.bind.annotation.XmlTransient;
20 import com.fasterxml.jackson.annotation.JsonInclude;
21 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24 import io.swagger.annotations.ApiModel;
25 import io.swagger.annotations.ApiModelProperty;
26 import it.polito.escape.verify.deserializer.NodeCustomDeserializer;
27 import it.polito.escape.verify.serializer.CustomMapSerializer;
29 @ApiModel(value = "Node")
31 @JsonDeserialize(using = NodeCustomDeserializer.class)
32 @JsonInclude(JsonInclude.Include.NON_EMPTY)
35 @ApiModelProperty(required = false, hidden = true)
39 @ApiModelProperty(required = true, example = "ep", value = "The name of the node can be any string")
42 @ApiModelProperty( required = true,
44 value = "The functional types that are currently supported are: endpoint, firewall, nat, antispam, webclient, webserver, mailclient, mailserver")
45 private String functional_type;
47 @ApiModelProperty(required = false, hidden = true)
49 private Configuration configuration = new Configuration();
51 @ApiModelProperty( name = "neighbours",
53 dataType = "List[it.polito.escape.verify.model.Neighbour]")
54 private Map<Long, Neighbour> neighbours = new HashMap<Long, Neighbour>();
56 @ApiModelProperty(required = false, hidden = true)
58 private Set<Link> links = new HashSet<>();
64 public Node(long id, String name, String functional_type, Configuration configuration) {
67 this.functional_type = functional_type;
68 this.configuration = configuration;
71 public String getName() {
75 public void setName(String name) {
79 public String getFunctional_type() {
80 return functional_type;
83 public void setFunctional_type(String functional_type) {
84 this.functional_type = functional_type;
88 public Configuration getConfiguration() {
92 public void setConfiguration(Configuration configuration) {
93 this.configuration = configuration;
96 @JsonSerialize(using = CustomMapSerializer.class)
97 public Map<Long, Neighbour> getNeighbours() {
101 public void setNeighbours(Map<Long, Neighbour> neighbours) {
102 this.neighbours = neighbours;
105 public long getId() {
109 public void setId(long id) {
113 public Set<Link> getLinks() {
117 public void setLinks(Set<Link> links) {
121 public void addLink(String url, String rel) {
122 Link link = new Link();
129 public int hashCode() {
130 final int prime = 31;
132 result = prime * result + ((name == null) ? 0 : name.hashCode());
137 public boolean equals(Object obj) {
144 public Neighbour searchNeighbourByName(String name) {
145 for (Neighbour neighbour : this.neighbours.values()) {
146 if (neighbour.getName().equals(name))