Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.model.core.io

File File.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
14% of files have more coverage

Code metrics

8
18
11
1
91
73
15
0.83
1.64
11
1.36

Classes

Class Line # Actions
File 17 18 15
0.729729773%
 

Contributing tests

This file is covered by 5 tests. .

Source view

1    package io.sunshower.model.core.io;
2   
3    import io.sunshower.common.Identifier;
4    import io.sunshower.model.core.Schemata;
5    import io.sunshower.persistence.core.DistributableEntity;
6    import io.sunshower.persistence.core.Hierarchical;
7    import java.util.Collection;
8    import java.util.HashSet;
9    import java.util.Set;
10    import javax.persistence.*;
11    import javax.xml.bind.annotation.*;
12   
13    /** @author haswell */
14    @Entity
15    @XmlRootElement(name = "file")
16    @Table(name = "FILE", schema = Schemata.SUNSHOWER)
 
17    public class File extends DistributableEntity implements Hierarchical<Identifier, File> {
18   
19    @Basic @XmlElement private String path;
20   
21    @XmlIDREF
22    @ManyToOne
23    @JoinColumn(name = "parent_id")
24    private File parent;
25   
26    @Basic @XmlAttribute private String extension;
27   
28    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
29    @XmlElement(name = "child")
30    @JoinColumn(name = "parent_id")
31    @XmlElementWrapper(name = "children")
32    private Set<File> children;
33   
 
34  2 toggle public String getExtension() {
35  2 return extension;
36    }
37   
 
38  1 toggle public void setExtension(String extension) {
39  1 this.extension = extension;
40    }
41   
 
42  5 toggle public File() {}
43   
 
44  5 toggle public File(String name) {
45  5 setPath(name);
46    }
47   
 
48  2 toggle public String getPath() {
49  2 return path;
50    }
51   
 
52  7 toggle public void setPath(String name) {
53  7 this.path = name;
54  7 if (name != null) {
55  7 final int idx = name.lastIndexOf('.');
56  7 if (idx > 0) {
57  1 final String ext = name.substring(idx + 1, name.length());
58  1 if (ext.length() < 10) {
59  1 setExtension(ext);
60    }
61    }
62    }
63    }
64   
 
65  0 toggle public void setChildren(Set<File> children) {
66  0 this.children = children;
67    }
68   
 
69  0 toggle @Override
70    public File getParent() {
71  0 return parent;
72    }
73   
 
74  2 toggle @Override
75    public Collection<File> getChildren() {
76  2 if (children == null) {
77  2 return (children = new HashSet<>());
78    }
79  0 return children;
80    }
81   
 
82  2 toggle @Override
83    public boolean addChild(File file) {
84  2 return getChildren().add(file);
85    }
86   
 
87  0 toggle @Override
88    public void setParent(File file) {
89  0 parent = file;
90    }
91    }