-
Notifications
You must be signed in to change notification settings - Fork 2
/
Model.java
52 lines (41 loc) · 1.05 KB
/
Model.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cz.cvut.fel.adaptiverestfulapi.meta.model;
import java.util.*;
/**
* Contains all metadata about model.
*/
public class Model {
private final String name;
private final Map<String, Entity> entities;
public Model(String name, Collection<Entity> entities) {
this.name = name;
this.entities = new HashMap<>();
for (Entity entity : entities) {
this.entities.put(entity.getName(), entity);
}
}
/**
* Returns name of the model.
* @return model name
*/
public String getName() {
return this.name;
}
/**
* Returns an immutable map of entities.
* @return entities
*/
public Map<String, Entity> getEntities() {
return Collections.unmodifiableMap(this.entities);
}
/**
* Returns entity for given name.
* @param name
* @return entity or null if not found
*/
public Entity entityForName(String name) {
if (name != null) {
return this.entities.get(name);
}
return null;
}
}