org.cactoos.iterable.Joined Java Examples
The following examples show how to use
org.cactoos.iterable.Joined.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RsWithStatus.java From takes with MIT License | 6 votes |
/** * Make head. * @param origin Original response * @param status Status * @param reason Reason * @return Head * @throws IOException If fails */ private static Iterable<String> head(final Response origin, final int status, final CharSequence reason) throws IOException { // @checkstyle MagicNumber (1 line) if (status < 100 || status > 999) { throw new IllegalArgumentException( String.format( // @checkstyle LineLength (1 line) "according to RFC 7230 HTTP status code must have three digits: %d", status ) ); } return new Joined<>( new FormattedText( "HTTP/1.1 %d %s", status, reason ).asString(), new Filtered<>( item -> new Not( new StartsWith(item, "HTTP/") ).value(), origin.head() ) ); }
Example #2
Source File: TkAll.java From jpeek with MIT License | 6 votes |
@Override public Response act(final Request req) { return new RsPage( req, "all", () -> new IterableOf<>( new XeAppend( "recent", new XeDirectives( new Joined<>( new Results().all() ) ) ) ) ); }
Example #3
Source File: TkMistakes.java From jpeek with MIT License | 6 votes |
@Override public Response act(final Request req) { return new RsPage( req, "mistakes", () -> new IterableOf<>( new XeAppend( "worst", new XeDirectives( new Joined<>( new HeadOf<Iterable<Directive>>( // @checkstyle MagicNumber (1 line) 20, new Mistakes().worst() ) ) ) ) ) ); }
Example #4
Source File: SetOfTest.java From cactoos with MIT License | 6 votes |
@Test public void behaveAsSetMergedCollectionsOfLiteralsWithDuplicates() { new Assertion<>( "Must keep unique string literals", new SetOf<String>( new Joined<String>( new IterableOf<>("cc", "ff"), new IterableOf<>("aa", "bb", "cc", "dd") ) ), new AllOf<>( new IterableOf<Matcher<? super SetOf<String>>>( new HasSize(5), new IsCollectionContaining<>(new IsEqual<>("aa")), new IsCollectionContaining<>(new IsEqual<>("bb")), new IsCollectionContaining<>(new IsEqual<>("cc")), new IsCollectionContaining<>(new IsEqual<>("dd")), new IsCollectionContaining<>(new IsEqual<>("ff")) ) ) ).affirm(); }
Example #5
Source File: HtCookies.java From cactoos-http with MIT License | 5 votes |
/** * Ctor. * @param rsp Response */ public HtCookies(final Input rsp) { super(() -> new Grouped<>( new Mapped<>( (Text entry) -> { final Iterable<Text> parts = new Split(entry, "="); if (new LengthOf(parts).intValue() != 2) { throw new IllegalArgumentException( "Incorrect HTTP Response cookie" ); } final Iterator<Text> iter = parts.iterator(); return new MapEntry<>( iter.next().asString(), iter.next().asString() ); }, new Joined<>( new Mapped<>( e -> new Split(e, ";\\s+"), new HtHeaders(rsp).get("set-cookie") ) ) ), MapEntry::getKey, MapEntry::getValue )); }
Example #6
Source File: TkIndex.java From jpeek with MIT License | 5 votes |
@Override public Response act(final Request req) { return new RsPage( req, "index", () -> new IterableOf<>( new XeAppend( "best", new XeDirectives( new Joined<>( new HeadOf<>( // @checkstyle MagicNumber (1 line) 20, new Results().best() ) ) ) ), new XeAppend( "recent", new XeDirectives( new Joined<>( new HeadOf<>( // @checkstyle MagicNumber (1 line) 25, new Results().recent() ) ) ) ) ) ); }
Example #7
Source File: MapOf.java From cactoos with MIT License | 5 votes |
/** * Ctor. * @param src Map to extend * @param list List of the entries * @since 0.12 */ @SuppressWarnings("unchecked") public MapOf(final Map<X, Y> src, final Iterable<Map.Entry<X, Y>> list) { this( new Joined<>( src.entrySet(), list ) ); }
Example #8
Source File: ApacheWire.java From verano-http with MIT License | 5 votes |
/** * Ctor. * @param uri Request uri * @param client Http client * @param parameters Parameters */ public ApacheWire( final String uri, final ApacheClient client, final Iterable<DictInput> parameters ) { this( client, new Joined<DictInput>(new RequestUri(uri), parameters) ); }
Example #9
Source File: Request.java From verano-http with MIT License | 5 votes |
/** * Ctor. * @param uri Uri * @param method Http method * @param inputs Inputs */ public Request( final String uri, final String method, final Iterable<DictInput> inputs ) { super( () -> new DictOf( new Joined<DictInput>( new IterableOf<>( new Path(uri), new Method(method) ), inputs ) ) ); }
Example #10
Source File: ExpectedStatus.java From verano-http with MIT License | 4 votes |
/** * Ctor. * @param status Status * @param additional Additional statuses */ public ExpectedStatus(final Integer status, final Integer... additional) { this( new Joined<>(status, new IterableOf<>(additional)), new TextOf("") ); }
Example #11
Source File: Base.java From jpeek with MIT License | 4 votes |
@Override public Iterable<Path> files() throws IOException { return new Joined<Path>(this.left.files(), this.right.files()); }
Example #12
Source File: GetMatch.java From verano-http with MIT License | 2 votes |
/** * Ctor. * @param matches Matches */ public GetMatch(final Iterable<MatchingCriteria> matches) { super(new Joined<>(new MethodMatch(new IsEqual<>("GET")), matches)); }
Example #13
Source File: MultiplicationOf.java From cactoos with MIT License | 2 votes |
/** * Ctor. * @param arg Required argument * @param src The numbers */ public MultiplicationOf(final Number arg, final Number... src) { this(new Joined<>(arg, new IterableOf<>(src))); }
Example #14
Source File: JoinedDict.java From verano-http with MIT License | 2 votes |
/** * Ctor. * @param dicts Dictionaries */ public JoinedDict(final Dict... dicts) { super(() -> new HashDict(new Joined<>(dicts))); }
Example #15
Source File: PutMatch.java From verano-http with MIT License | 2 votes |
/** * Ctor. * @param matches Matches */ public PutMatch(final Iterable<MatchingCriteria> matches) { super(new Joined<>(new MethodMatch(new IsEqual<>("PUT")), matches)); }
Example #16
Source File: DeleteMatch.java From verano-http with MIT License | 2 votes |
/** * Ctor. * @param matches Matches */ public DeleteMatch(final Iterable<MatchingCriteria> matches) { super(new Joined<>(new MethodMatch(new IsEqual<>("DELETE")), matches)); }
Example #17
Source File: PostMatch.java From verano-http with MIT License | 2 votes |
/** * Ctor. * @param matches Matches */ public PostMatch(final Iterable<MatchingCriteria> matches) { super(new Joined<>(new MethodMatch(new IsEqual<>("POST")), matches)); }