Profile: Add function to copy config from another profile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
f84d178e46
commit
c72d30a1af
@ -32,15 +32,15 @@ public class Profile extends BaseObservable implements Copyable<Profile>, Observ
|
||||
|
||||
public Profile(String name) {
|
||||
super();
|
||||
if (!isNameValid(name))
|
||||
throw new IllegalArgumentException();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private Profile(Profile original)
|
||||
throws IOException {
|
||||
this(original.getName());
|
||||
final byte configBytes[] = original.toString().getBytes(StandardCharsets.UTF_8);
|
||||
final ByteArrayInputStream configStream = new ByteArrayInputStream(configBytes);
|
||||
parseFrom(configStream);
|
||||
parseFrom(original);
|
||||
}
|
||||
|
||||
public Profile copy() {
|
||||
@ -90,6 +90,13 @@ public class Profile extends BaseObservable implements Copyable<Profile>, Observ
|
||||
}
|
||||
}
|
||||
|
||||
public void parseFrom(Profile profile)
|
||||
throws IOException {
|
||||
final byte configBytes[] = profile.toString().getBytes(StandardCharsets.UTF_8);
|
||||
final ByteArrayInputStream configStream = new ByteArrayInputStream(configBytes);
|
||||
parseFrom(configStream);
|
||||
}
|
||||
|
||||
public void setIsConnected(boolean isConnected) {
|
||||
this.isConnected = isConnected;
|
||||
notifyPropertyChanged(BR.isConnected);
|
||||
|
Loading…
Reference in New Issue
Block a user