TypeBound.java
01 /*
02  * Java Genetic Algorithm Library (jenetics-1.5.0).
03  * Copyright (c) 2007-2013 Franz Wilhelmstötter
04  *
05  * Licensed under the Apache License, Version 2.0 (the "License");
06  * you may not use this file except in compliance with the License.
07  * You may obtain a copy of the License at
08  *
09  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * Author:
18  *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
19  */
20 package org.jenetics.internal.util;
21 
22 import org.jenetics.util.Function;
23 import org.jenetics.util.StaticObject;
24 
25 
26 /**
27  @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
28  @since 1.2
29  @version 1.2 &mdash; <em>$Date: 2013-09-01 $</em>
30  */
31 public final class TypeBound extends StaticObject {
32 
33     public static class Extends<A, B> implements Function<A, B> {
34         private Extends() {
35         }
36 
37         @Override
38         @SuppressWarnings("unchecked")
39         public B apply(final A value) {
40             return (B)value;
41         }
42     }
43 
44     public static final class Equals<A, B> extends Extends<A, B> {
45         private Equals() {
46         }
47     }
48 
49 
50 
51     public static <T> Equals<T, T> Equals() {
52         return new Equals<>();
53     }
54 
55     public static <B, A extends B> Extends<A, B> Extends() {
56         return new Extends<>();
57     }
58 
59 
60     private TypeBound() {}
61 
62 
63 
64 /*
65 
66     static interface Seq<T> {
67         public boolean allTrue(final Equals<T, Boolean> bound);
68         public int sum(final Extends<T, Number> bound);
69     }
70 
71     static void main() {
72         final Seq<String> strings = null;
73         final Seq<Boolean> booleans = null;
74         final Seq<Integer> ints = null;
75 
76         //strings.allTrue(TypeBound.<Boolean>Equals());
77         booleans.allTrue(TypeBound.<Boolean>Equals());
78 
79         ints.sum(TypeBound.<Number, Integer>Extends());
80     }
81 */
82 
83 }
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96