Thu, 15 Oct 2020 20:02:30 +0200
changes request mapping to contain project and version ID as path parameters (this removes the session storage)
universe@127 | 1 | package de.uapcore.lightpit.types; |
universe@127 | 2 | |
universe@127 | 3 | public final class WebColor { |
universe@127 | 4 | |
universe@127 | 5 | private final String hex; |
universe@127 | 6 | |
universe@127 | 7 | /** |
universe@127 | 8 | * Constructs a color object from a hex string. |
universe@127 | 9 | * @param hex the 6 digits hex string optionally preceded by a hash symbol |
universe@127 | 10 | * @throws IllegalArgumentException if the given string does not specify a color |
universe@127 | 11 | */ |
universe@127 | 12 | public WebColor(String hex) throws IllegalArgumentException { |
universe@127 | 13 | this.hex = (hex.startsWith("#") ? hex : ("#"+hex)).toUpperCase(); |
universe@127 | 14 | if (!this.hex.matches("#[0-9A-F]{6}")) |
universe@127 | 15 | throw new IllegalArgumentException(hex+" is not a color"); |
universe@127 | 16 | } |
universe@127 | 17 | |
universe@127 | 18 | /** |
universe@127 | 19 | * Returns the hex representation without th leading hash symbol. |
universe@127 | 20 | * @return the hex representation of this color (e.g. FF0000 for red) |
universe@127 | 21 | */ |
universe@127 | 22 | public String getHex() { |
universe@127 | 23 | return hex.substring(1); |
universe@127 | 24 | } |
universe@127 | 25 | |
universe@127 | 26 | @Override |
universe@127 | 27 | public String toString() { |
universe@127 | 28 | return hex; |
universe@127 | 29 | } |
universe@127 | 30 | } |