Skip to content

Other Utilities

eugener edited this page Jul 3, 2012 · 2 revisions

Deep Copy

The common need in programming is to make defensive copies of the objects. The standard Java clone facility allows only for shallow copying. And even then every class have to be outfitted with specialized code.

DeepCopy is capable of making a copy of any class as long as this class is serializable (implements Serializable interface).

 List<String> strings = DeepCopy.copy( Arrays.asList("aaa", "bbb"));

Implementation is extremely fast and based on memory streams, optimized for speed and stripped of any synchronization code.

Operating System

This is an enum which allows to find out what the current OS is and retrieve some of it's properties. Usage example:

switch( OperatingSystem.getCurrent() ) {
   case MACOS  : return new MacOsContentDesign();
   case LINUX  : return new LinuxContentDesign();
   case WINDOWS: return new WindowsContentDesign();
   default   : return new DefaultContentDesign();
}

Operating system properties available:

  • Name
  • Version
  • Archtecture