1 package io.github.reggert.reb4j;
2
3 import java.util.regex.Pattern;
4
5 import fj.data.LazyString;
6
7
8
9
10
11
12
13
14
15 public final class Adopted extends AbstractExpression
16 {
17 private static final long serialVersionUID = 1L;
18 public final LazyString expression;
19
20 private Adopted(final String expression)
21 {this.expression = LazyString.str(expression);}
22
23 @Override
24 public LazyString expression()
25 {return expression;}
26
27
28
29
30
31
32
33
34
35
36 public static Adopted fromPattern(final Pattern pattern)
37 {
38 if (pattern == null)
39 throw new NullPointerException("pattern");
40 return new Adopted(pattern.pattern());
41 }
42
43 @Override
44 public int hashCode()
45 {
46 final int prime = 31;
47 int result = 1;
48 result = prime * result + (expression.toString().hashCode());
49 return result;
50 }
51
52 @Override
53 public boolean equals(final Object obj)
54 {
55 if (this == obj)
56 return true;
57 if (obj == null)
58 return false;
59 if (getClass() != obj.getClass())
60 return false;
61 final Adopted other = (Adopted) obj;
62 return expression.toString().equals(other.expression.toString());
63 }
64
65 @Override
66 public Integer boundedLength()
67 {
68 return null;
69 }
70
71 @Override
72 public boolean repetitionInvalidatesBounds()
73 {
74 return true;
75 }
76
77 @Override
78 public boolean possiblyZeroLength()
79 {
80 return true;
81 }
82 }