This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface groups to the data model
This adds support for interface groups to the data model, but does not yet provide any commands to manipulate them. Affects: #24
- Loading branch information
Showing
25 changed files
with
523 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...m.waxmill.machines/src/main/java/com/io7m/waxmill/machines/WXMInterfaceGroupNameType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright © 2020 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.waxmill.machines; | ||
|
||
import com.io7m.immutables.styles.ImmutablesStyleType; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* A TAP device name, such as {@code tap23}. | ||
*/ | ||
|
||
@Value.Immutable | ||
@ImmutablesStyleType | ||
public interface WXMInterfaceGroupNameType | ||
{ | ||
/** | ||
* @return The device name | ||
*/ | ||
|
||
@Value.Parameter | ||
String value(); | ||
|
||
/** | ||
* Check preconditions for the type. | ||
*/ | ||
|
||
@Value.Check | ||
default void checkPreconditions() | ||
{ | ||
WXMInterfaceGroupNames.checkValid(this.value()); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...io7m.waxmill.machines/src/main/java/com/io7m/waxmill/machines/WXMInterfaceGroupNames.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright © 2020 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.waxmill.machines; | ||
|
||
import java.util.Objects; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Functions over interface group names. | ||
*/ | ||
|
||
public final class WXMInterfaceGroupNames | ||
{ | ||
private static final Pattern VALID_NAME = | ||
Pattern.compile("[A-Za-z_]{1,15}"); | ||
|
||
private WXMInterfaceGroupNames() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param name The raw name string | ||
* | ||
* @return {@code true} if the given string represents a valid interface group name | ||
*/ | ||
|
||
public static boolean isValid( | ||
final String name) | ||
{ | ||
return VALID_NAME.matcher( | ||
Objects.requireNonNull(name, "name") | ||
).matches(); | ||
} | ||
|
||
/** | ||
* Check that a string represents a valid interface group name. | ||
* | ||
* @param name The raw name string | ||
* | ||
* @return {@code name} | ||
* | ||
* @throws IllegalArgumentException If the string is not a interface group name | ||
*/ | ||
|
||
public static String checkValid( | ||
final String name) | ||
{ | ||
if (isValid(name)) { | ||
return name; | ||
} | ||
throw new IllegalArgumentException( | ||
String.format("Invalid name '%s': Must match %s", name, VALID_NAME) | ||
); | ||
} | ||
} |
Oops, something went wrong.