-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70a1667
commit 907395e
Showing
38 changed files
with
717 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
core/src/main/java/com/envimate/httpmate/path/AnyMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2019 envimate GmbH - https://envimate.com/. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.envimate.httpmate.path; | ||
|
||
import com.envimate.httpmate.path.statemachine.StateMachineMatcher; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@EqualsAndHashCode | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class AnyMatcher implements StateMachineMatcher<String> { | ||
|
||
static boolean isRecursiveWildcard(final String stringSpecification) { | ||
return "*".equals(stringSpecification); | ||
} | ||
|
||
static StateMachineMatcher<String> anyMatcher() { | ||
return new AnyMatcher(); | ||
} | ||
|
||
@Override | ||
public Optional<Map<String, String>> matchAndReturnCaptures(final String element) { | ||
return Optional.of(Map.of()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "*"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/com/envimate/httpmate/path/statemachine/ElementPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2019 envimate GmbH - https://envimate.com/. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.envimate.httpmate.path.statemachine; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@ToString | ||
@EqualsAndHashCode | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class ElementPosition<T> { | ||
private final int index; | ||
private final List<T> elements; | ||
|
||
public static <T> ElementPosition<T> start(final List<T> elements) { | ||
return new ElementPosition<>(0, elements); | ||
} | ||
|
||
public boolean isEnd() { | ||
return elements.size() <= index; | ||
} | ||
|
||
public ElementPosition<T> next() { | ||
return new ElementPosition<>(index + 1, elements); | ||
} | ||
|
||
public T get() { | ||
if (isEnd()) { | ||
throw new IndexOutOfBoundsException(); | ||
} | ||
return elements.get(index); | ||
} | ||
} |
Oops, something went wrong.