@Override public boolean isMatch(final Request a, final Request b) { return all(rules.iterator(), new Predicate<MatchRule>() { @Override public boolean apply(MatchRule rule) { return rule.isMatch(a, b); } }); }
static int checkPositionIndex(int index, int size, @Nullable String desc) { // Carefully optimized for execution by hotspot (explanatory comment above) if (index < 0 || index > size) { throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc)); } return index; }
@SuppressWarnings("unchecked") // safe covariant cast @Override Optional<T> or(Optional<? extends T> secondChoice) { return (Optional<T>) checkNotNull(secondChoice); }
String contentType() { String header = headers.get(CONTENT_TYPE); if (isNullOrEmpty(header)) { return DEFAULT_CONTENT_TYPE; } else { return MediaType.parse(header).toString(); } }
@Override public Reader readerFor(String tapeFileName) { File file = new File(root, tapeFileName); try { return newReader(file, Charset.forName(FILE_CHARSET)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }
@Override public Writer writerFor(String tapePath) { File file = new File(root, tapePath); //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); try { return newWriter(file, Charset.forName(FILE_CHARSET)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }
private synchronized int findMatch(final Request request) { return Util.indexOf(interactions.iterator(), new Predicate<YamlRecordedInteraction>() { @Override public boolean apply(YamlRecordedInteraction input) { return matchRule.isMatch(request, input.toImmutable().request()); } }); }
static int checkPositionIndex(int index, int size) { return checkPositionIndex(index, size, "index"); }
@Override public int compare(Property a, Property b) { return Util.compare(propertyNames.indexOf(a.getName()), propertyNames.indexOf(b.getName())); } }
String contentType() { String header = headers.get(CONTENT_TYPE); if (isNullOrEmpty(header)) { return DEFAULT_CONTENT_TYPE; } else { return MediaType.parse(header).toString(); } }
@Override public Reader readerFor(String tapeFileName) { File file = new File(root, tapeFileName); try { return newReader(file, Charset.forName(FILE_CHARSET)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }
@Override public Writer writerFor(String tapePath) { File file = new File(root, tapePath); //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); try { return newWriter(file, Charset.forName(FILE_CHARSET)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }
private synchronized int findMatch(final Request request) { return Util.indexOf(interactions.iterator(), new Predicate<YamlRecordedInteraction>() { @Override public boolean apply(YamlRecordedInteraction input) { return matchRule.isMatch(request, input.toImmutable().request()); } }); }
static int checkPositionIndex(int index, int size) { return checkPositionIndex(index, size, "index"); }
@Override Optional<T> or(Optional<? extends T> secondChoice) { checkNotNull(secondChoice); return this; }
@Override public String getContentType() { String header = header(CONTENT_TYPE); if (isNullOrEmpty(header)) { return DEFAULT_CONTENT_TYPE; } else { return MediaType.parse(header).toString(); } }
static int checkPositionIndex(int index, int size, @Nullable String desc) { // Carefully optimized for execution by hotspot (explanatory comment above) if (index < 0 || index > size) { throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc)); } return index; }
@Override public boolean isMatch(final Request a, final Request b) { return all(rules.iterator(), new Predicate<MatchRule>() { @Override public boolean apply(MatchRule rule) { return rule.isMatch(a, b); } }); }
@Override T or(T defaultValue) { return checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)"); }
@Override public String getContentType() { String header = header(CONTENT_TYPE); if (isNullOrEmpty(header)) { return DEFAULT_CONTENT_TYPE; } else { return MediaType.parse(header).toString(); } }