Clean up CzmlFile
Another small cleaning up for CzmlFile:
-
abstractPrimaryObjects
→ Rename to objects or czmlPrimaryObjects if you like the long names ;)- Should be a list of
CzmlPrimaryObject
(use the interface for genericity, instead of the abstract class) - Add a public method
getId()
toCzmlPrimaryObject
- Should be a list of
-
stringWriter
: does it need to be static ? It's only used to create a default CesiumOutputStream -
CesiumOutputStream output
, only really used inwrite()
method → should be initialized at the beginning of this method -
`CesiumStreamWriter streamWriter: same
-
String pathDirectory
: there are methods in Java to get parent directory and create it.In your case:
File file = new File(filePath);
thenfile.getParentFile().mkdirs();
Can be done on the fly just before writing the actual file.
-
String pathFile
and `write()` method. IMHO we shouldn't store thepathFile
but have a signature `write(String)` or `write(File)`(and then `pathFile` shall be removed from the builder too
-
`NUMBER_OF_POLYLINE_IN_FILE` and associated functions: only used in `FieldOfObservation`. Move them here?
-
`header`, `setHeader`: user can set the header but then in write method it is overwritten. I think the attribute and class could be removed
-
Also, at start of write(), an empty-check is done on the list. The exception is NO_HEADER but then the header is taken from the list, so the exception should be EMPTY_LIST ??
-
`containsInstance` and `indexOfInstance`: why not just `getHeader()` that loops on objects and catch the Header?
-
Removing duplicates in write():
- `noDuplicates.add(objects.get(0));` is that supposed to be the Header?
- In the loop: current object is compared to previous from ids, what happened if two objects have the same ID but are not consecutive? In a nutshell, what is the point of the "remove duplicates" block of code?