Skip to content

Commit 16748b6

Browse files
committed
merging master, resolving conflict
2 parents 69e1df0 + 6cb8ae4 commit 16748b6

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

core/src/main/java/org/everit/json/schema/StringSchema.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ Pattern getRE2JPattern() {
120120
}
121121

122122
public java.util.regex.Pattern getPattern() {
123-
return java.util.regex.Pattern.compile(pattern.toString());
123+
if (pattern == null) {
124+
return null;
125+
} else {
126+
return java.util.regex.Pattern.compile(pattern.toString());
127+
}
124128
}
125129

126130
@Override void accept(Visitor visitor) {

core/src/test/java/org/everit/json/schema/StringSchemaTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
/*
2-
* Copyright (C) 2011 Everit Kft. (http://www.everit.org)
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-
* http://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-
*/
161
package org.everit.json.schema;
172

183
import static org.everit.json.schema.ObjectComparator.deepEquals;
194
import static org.everit.json.schema.TestSupport.buildWithLocation;
5+
import static org.junit.Assert.assertEquals;
6+
import static org.junit.Assert.assertNull;
207
import static org.junit.Assert.assertTrue;
218

229
import java.util.Optional;
@@ -178,4 +165,19 @@ public void requiresString_nullable() {
178165
Schema subject = StringSchema.builder().requiresString(true).nullable(true).build();
179166
subject.validate(JSONObject.NULL);
180167
}
168+
169+
@Test
170+
public void getConvertedPattern() {
171+
StringSchema subject = StringSchema.builder().pattern("my\\\\/[p]a[tt]ern").build();
172+
assertEquals("my\\\\/[p]a[tt]ern", subject.getRE2JPattern().toString());
173+
assertEquals("my\\\\/[p]a[tt]ern", subject.getPattern().toString());
174+
}
175+
176+
@Test
177+
public void getConvertedNullPattern() {
178+
StringSchema subject = StringSchema.builder().build();
179+
assertNull(subject.getRE2JPattern());
180+
assertNull(subject.getPattern());
181+
}
182+
181183
}

0 commit comments

Comments
 (0)