1 package org.kuali.common.util.system; 2 3 import javax.validation.Valid; 4 5 import org.kuali.common.util.bind.api.Bind; 6 import org.kuali.common.util.bind.api.BindingAlias; 7 import org.kuali.common.util.bind.api.BindingPrefix; 8 import org.kuali.common.util.bind.api.NoBindingPrefix; 9 import org.kuali.common.util.build.AwesomeBuilder; 10 import org.kuali.common.util.validate.IdiotProofImmutable; 11 12 @IdiotProofImmutable 13 @NoBindingPrefix 14 public final class SystemProperties { 15 16 @Valid 17 @Bind 18 private final User user; 19 20 @Valid 21 @Bind 22 @BindingPrefix("os") 23 private final OperatingSystem operatingSystem; 24 25 @Valid 26 @Bind 27 private final Java java; 28 29 @BindingAlias("line.separator") 30 private final String lineSeparator; 31 32 @BindingAlias("path.separator") 33 private final String pathSeparator; 34 35 @BindingAlias("file.separator") 36 private final String fileSeparator; 37 38 private SystemProperties(Builder builder) { 39 this.user = builder.user; 40 this.operatingSystem = builder.operatingSystem; 41 this.java = builder.java; 42 this.lineSeparator = builder.lineSeparator; 43 this.pathSeparator = builder.pathSeparator; 44 this.fileSeparator = builder.fileSeparator; 45 } 46 47 public static Builder builder() { 48 return new Builder(); 49 } 50 51 public static class Builder extends AwesomeBuilder<SystemProperties> { 52 53 private User user; 54 private OperatingSystem operatingSystem; 55 private Java java; 56 private String pathSeparator; 57 private String lineSeparator; 58 private String fileSeparator; 59 60 @Override 61 public SystemProperties getInstance() { 62 return new SystemProperties(this); 63 } 64 65 public Builder user(User user) { 66 this.user = user; 67 return this; 68 } 69 70 public Builder operatingSystem(OperatingSystem operatingSystem) { 71 this.operatingSystem = operatingSystem; 72 return this; 73 } 74 75 public Builder java(Java java) { 76 this.java = java; 77 return this; 78 } 79 80 public Builder lineSeparator(String lineSeparator) { 81 this.lineSeparator = lineSeparator; 82 return this; 83 } 84 85 public Builder pathSeparator(String pathSeparator) { 86 this.pathSeparator = pathSeparator; 87 return this; 88 } 89 90 public Builder fileSeparator(String fileSeparator) { 91 this.fileSeparator = fileSeparator; 92 return this; 93 } 94 95 public User getUser() { 96 return user; 97 } 98 99 public void setUser(User user) { 100 this.user = user; 101 } 102 103 public OperatingSystem getOperatingSystem() { 104 return operatingSystem; 105 } 106 107 public void setOperatingSystem(OperatingSystem operatingSystem) { 108 this.operatingSystem = operatingSystem; 109 } 110 111 public Java getJava() { 112 return java; 113 } 114 115 public void setJava(Java java) { 116 this.java = java; 117 } 118 119 public String getLineSeparator() { 120 return lineSeparator; 121 } 122 123 public void setLineSeparator(String lineSeparator) { 124 this.lineSeparator = lineSeparator; 125 } 126 127 public String getPathSeparator() { 128 return pathSeparator; 129 } 130 131 public void setPathSeparator(String pathSeparator) { 132 this.pathSeparator = pathSeparator; 133 } 134 135 public String getFileSeparator() { 136 return fileSeparator; 137 } 138 139 public void setFileSeparator(String fileSeparator) { 140 this.fileSeparator = fileSeparator; 141 } 142 143 } 144 145 public User getUser() { 146 return user; 147 } 148 149 public OperatingSystem getOperatingSystem() { 150 return operatingSystem; 151 } 152 153 public Java getJava() { 154 return java; 155 } 156 157 public String getLineSeparator() { 158 return lineSeparator; 159 } 160 161 public String getPathSeparator() { 162 return pathSeparator; 163 } 164 165 public String getFileSeparator() { 166 return fileSeparator; 167 } 168 169 }