All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.windowsazure.samples.internal.table.IfMatch Maven / Gradle / Ivy

package com.windowsazure.samples.internal.table;

import java.util.Vector;


public final class IfMatch {

	public static final IfMatch WILD = new IfMatch("*");
	
	public IfMatch() {}
	
	public IfMatch(String... args) {
		for (String pattern : args) {
			addPattern(pattern);
		}
	}
	
	public void addPattern(String pattern) {
		if (! hasPattern(pattern))
			patterns.add(pattern);
	}
	
	public String getRepresentation() {
		if (hasPattern("*"))
			return "*";
		
		StringBuilder sb = new StringBuilder();
		for (String pattern : patterns) {
			sb.append(pattern);
			sb.append(", ");
		}
		
		String result = sb.toString();
		return result.substring(0, result.length() - 1);
	}
	
	private boolean hasPattern(String pattern) {
		for (String item : patterns) {
			if (item.equals(pattern))
				return true;
		}
		return false;
	}
	
	private Vector patterns = new Vector();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy