org.metaeffekt.artifact.resolver.alpine.bodge.StringPiece Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2021-2024 the original author or authors.
*
* Licensed 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 org.metaeffekt.artifact.resolver.alpine.bodge;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* A piece of a string to be constructed.
* Pieces are a "literal" and/or a derivation by defining "fromKey" and a regex match to apply.
*
* Consider defining EITHER "literal" OR some derivation for better readability, not both.
*/
@Getter
@Setter
@ToString
public class StringPiece {
public enum RefValue {
PKGVER,
PKGREL,
ALPINE_VERSION;
@JsonCreator
public static RefValue getRefValue(String value) {
return valueOf(value.toUpperCase(Locale.ENGLISH));
}
@JsonValue
public String value() {
return name().toLowerCase(Locale.ENGLISH);
}
}
/**
* A literal piece of text that will be appended as-is.
*
* This is appended before any other step in this piece.
*/
private String literal = "";
/**
* Defines a reference attribute key, the raw value of which can be further processed using derivations.
*
* Leaving it empty just skips all derivation steps.
*/
private RefValue fromValue = null;
/**
* Regex actions to apply.
*/
private List actions = new ArrayList<>();
/**
* A java (regex) matcher pattern to use to get the piece from previously processed input.
*
* This is the final processing step, returning the result of all previous processing.
*
* Matches absolutely everything by default.
*/
private String finallyMatch = "[\\s\\S]*";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy