File tree Expand file tree Collapse file tree
main/java/com/google/cloud/dlp/v2beta1
test/java/com/google/cloud/dlp/v2beta1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package com .google .cloud .dlp .v2beta1 ;
17+
18+ import com .google .privacy .dlp .v2beta1 .Color ;
19+
20+ public class Colors {
21+
22+ private Colors () {}
23+
24+ public static final Color asDlpColor (java .awt .Color c ) {
25+ return Color .newBuilder ()
26+ .setBlue (c .getBlue ())
27+ .setGreen (c .getGreen ())
28+ .setRed (c .getRed ())
29+ .build ();
30+ }
31+
32+ public static final java .awt .Color asAwtColor (Color c ) {
33+ return new java .awt .Color (c .getRed () / 255 , c .getGreen () / 255 , c .getBlue () / 255 );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ package com .google .cloud .dlp .v2beta1 ;
2+
3+ import com .google .privacy .dlp .v2beta1 .Color ;
4+ import org .junit .Assert ;
5+ import org .junit .Test ;
6+
7+ public class ColorTest {
8+
9+ @ Test
10+ public void asDlpColorTest () {
11+ Color got = Colors .asDlpColor (new java .awt .Color (1 , 2 , 3 ));
12+ Assert .assertEquals (got .getBlue (), 3 , 0 );
13+ Assert .assertEquals (got .getGreen (), 2 , 0 );
14+ Assert .assertEquals (got .getRed (), 1 , 0 );
15+ }
16+
17+ @ Test
18+ public void asAwtColorTest () {
19+ java .awt .Color got =
20+ Colors .asAwtColor (Color .newBuilder ().setRed (1 ).setGreen (2 ).setBlue (3 ).build ());
21+
22+ Assert .assertEquals (got .getBlue (), 3 , 0 );
23+ Assert .assertEquals (got .getGreen (), 2 , 0 );
24+ Assert .assertEquals (got .getRed (), 1 , 0 );
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments