com.metaeffekt.artifact.terms.model.MatchItem Maven / Gradle / Ivy
/*
* 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 com.metaeffekt.artifact.terms.model;
import com.metaeffekt.artifact.analysis.utils.StringStats;
public class MatchItem {
public String deriveColor(TermsMetaData contextLicenseMetaData) {
int r = 200;
int g = 200;
int b = 200;
String a = "0.5";
switch (matchType) {
case GRANT_MATCH:
r = 0;
g = 200;
b = 0;
break;
case OBLIGATION_MATCH:
r = 200;
g = 200;
b = 0;
break;
case EVIDENCE_MATCH:
r = 0;
g = 200;
b = 200;
break;
case EVIDENCE_EXCLUDE:
r = 200;
g = 0;
b = 0;
break;
}
if (contextLicenseMetaData == this.sourceLicenseMetaData) {
a = "0.7";
}
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
}
public static enum MatchType {
EVIDENCE_MATCH,
EVIDENCE_ONE_OF_MATCH,
EVIDENCE_EXCLUDE,
GRANT_MATCH,
OBLIGATION_MATCH,
NAME_MATCH,
REFERENCE_MATCH,
IGNORED_NAME_MATCH,
NOT_MATCHED;
}
private final StringStats matchStringStats;
private final MatchType matchType;
private final TermsMetaData sourceLicenseMetaData;
private final CharSequence matchContext;
public MatchItem(StringStats matchStringStats, MatchType matchType, CharSequence matchContext,
TermsMetaData sourceLicenseMetaData) {
this.matchStringStats = matchStringStats;
this.matchType = matchType;
this.matchContext = matchContext;
this.sourceLicenseMetaData = sourceLicenseMetaData;
}
public StringStats getMatchStringStats() {
return matchStringStats;
}
public MatchType getMatchType() {
return matchType;
}
public CharSequence getMatchContext() {
return matchContext;
}
public TermsMetaData getSourceLicenseMetaData() {
return sourceLicenseMetaData;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy