*/
package org.sonar.channel;
-public abstract class Channel<OUTPUT> {
+public abstract class Channel<O> {
/**
* Tries to consume the character stream at the current reading cursor position (provided by the {@link org.sonar.channel.CodeReader}). If
* the OUTPUT that can be optionally fed by the Channel
* @return false if the Channel doesn't want to consume the character stream, true otherwise.
*/
- public abstract boolean consume(CodeReader code, OUTPUT output);
+ public abstract boolean consume(CodeReader code, O output);
}
* declared for the CodeReader.
*
*/
-public final class ChannelCodeReaderFilter<OUTPUT> extends CodeReaderFilter<OUTPUT> {
+public final class ChannelCodeReaderFilter<O> extends CodeReaderFilter<O> {
@SuppressWarnings("unchecked")
- private Channel<OUTPUT>[] channels = new Channel[0];
+ private Channel<O>[] channels = new Channel[0];
private CodeReader internalCodeReader;
* @param channels
* the different channels
*/
- public ChannelCodeReaderFilter(Channel<OUTPUT>... channels) {
+ public ChannelCodeReaderFilter(Channel<O>... channels) {
super();
this.channels = channels;
}
* @param channels
* the different channels
*/
- public ChannelCodeReaderFilter(OUTPUT output, Channel<OUTPUT>... channels) {
+ public ChannelCodeReaderFilter(O output, Channel<O>... channels) {
super(output);
this.channels = channels;
}
break;
}
boolean consumed = false;
- for (Channel<OUTPUT> channel : channels) {
+ for (Channel<O> channel : channels) {
if (channel.consume(internalCodeReader, getOutput())) {
consumed = true;
break;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ChannelDispatcher<OUTPUT> extends Channel<OUTPUT> {
+public class ChannelDispatcher<O> extends Channel<O> {
private static final Logger LOG = LoggerFactory.getLogger(ChannelDispatcher.class);
private final boolean failIfNoChannelToConsumeOneCharacter;
- private final Channel<OUTPUT>[] channels;
+ private final Channel<O>[] channels;
/**
* @deprecated in version 2.9. Please use the builder() method
}
@Override
- public boolean consume(CodeReader code, OUTPUT output) {
+ public boolean consume(CodeReader code, O output) {
int nextChar = code.peek();
while (nextChar != -1) {
boolean characterConsumed = false;
- for (Channel<OUTPUT> channel : channels) {
+ for (Channel<O> channel : channels) {
if (channel.consume(code, output)) {
characterConsumed = true;
break;
* @see CodeBufferTest#testSeveralCodeReaderFilter()
*
*/
-public abstract class CodeReaderFilter<OUTPUT> {
+public abstract class CodeReaderFilter<O> {
private Reader reader;
- private OUTPUT output;
+ private O output;
private CodeReaderConfiguration configuration;
public CodeReaderFilter() {
}
- public CodeReaderFilter(OUTPUT output) {
+ public CodeReaderFilter(O output) {
this.output = output;
}
*
* @return the output
*/
- public OUTPUT getOutput() {
+ public O getOutput() {
return output;
}
* @param output
* the output to set
*/
- public void setOutput(OUTPUT output) {
+ public void setOutput(O output) {
this.output = output;
}
/**
* The RegexChannel can be used to be called each time the next characters in the character stream match a regular expression
*/
-public abstract class RegexChannel<OUTPUT> extends Channel<OUTPUT> {
+public abstract class RegexChannel<O> extends Channel<O> {
private final StringBuilder tmpBuilder = new StringBuilder();
private final Matcher matcher;
}
@Override
- public final boolean consume(CodeReader code, OUTPUT output) {
+ public final boolean consume(CodeReader code, O output) {
if (code.popTo(matcher, tmpBuilder) > 0) {
consume(tmpBuilder, output);
tmpBuilder.delete(0, tmpBuilder.length());
* @param the
* OUPUT object which can be optionally fed
*/
- protected abstract void consume(CharSequence token, OUTPUT output);
+ protected abstract void consume(CharSequence token, O output);
}
/**
* @since 2.3
*/
-public abstract class CheckFactory<CHECK> {
+public abstract class CheckFactory<C> {
- private Map<ActiveRule, CHECK> checkByActiveRule = Maps.newIdentityHashMap();
- private Map<CHECK, ActiveRule> activeRuleByCheck = Maps.newIdentityHashMap();
+ private Map<ActiveRule, C> checkByActiveRule = Maps.newIdentityHashMap();
+ private Map<C, ActiveRule> activeRuleByCheck = Maps.newIdentityHashMap();
private RulesProfile profile;
private String repositoryKey;
checkByActiveRule.clear();
activeRuleByCheck.clear();
for (ActiveRule activeRule : profile.getActiveRulesByRepository(repositoryKey)) {
- CHECK check = createCheck(activeRule);
+ C check = createCheck(activeRule);
checkByActiveRule.put(activeRule, check);
activeRuleByCheck.put(check, activeRule);
}
}
- abstract CHECK createCheck(ActiveRule activeRule);
+ abstract C createCheck(ActiveRule activeRule);
public final String getRepositoryKey() {
return repositoryKey;
}
- public final Collection<CHECK> getChecks() {
+ public final Collection<C> getChecks() {
return checkByActiveRule.values();
}
- public final CHECK getCheck(ActiveRule activeRule) {
+ public final C getCheck(ActiveRule activeRule) {
return checkByActiveRule.get(activeRule);
}
- public final ActiveRule getActiveRule(CHECK check) {
+ public final ActiveRule getActiveRule(C check) {
return activeRuleByCheck.get(check);
}
}
/**
* @since 1.10
*/
-public class PropertiesBuilder<KEY, VALUE> {
+public class PropertiesBuilder<K, V> {
private Metric metric;
- private Map<KEY, VALUE> props;
+ private Map<K, V> props;
- public PropertiesBuilder(Metric metric, Map<KEY, VALUE> map) {
- this.props = new TreeMap<KEY, VALUE>(map);
+ public PropertiesBuilder(Metric metric, Map<K, V> map) {
+ this.props = new TreeMap<K, V>(map);
this.metric = metric;
}
public PropertiesBuilder(Metric metric) {
- this.props = new TreeMap<KEY, VALUE>();
+ this.props = new TreeMap<K, V>();
this.metric = metric;
}
public PropertiesBuilder() {
- this.props = new TreeMap<KEY, VALUE>();
+ this.props = new TreeMap<K, V>();
}
- public PropertiesBuilder<KEY, VALUE> clear() {
+ public PropertiesBuilder<K, V> clear() {
this.props.clear();
return this;
}
- public Map<KEY, VALUE> getProps() {
+ public Map<K, V> getProps() {
return props;
}
return metric;
}
- public PropertiesBuilder<KEY, VALUE> setMetric(Metric metric) {
+ public PropertiesBuilder<K, V> setMetric(Metric metric) {
this.metric = metric;
return this;
}
- public PropertiesBuilder<KEY, VALUE> add(KEY key, VALUE value) {
+ public PropertiesBuilder<K, V> add(K key, V value) {
props.put(key, value);
return this;
}
- public PropertiesBuilder<KEY, VALUE> addAll(Map<KEY, VALUE> map) {
+ public PropertiesBuilder<K, V> addAll(Map<K, V> map) {
props.putAll(map);
return this;
}
* @deprecated since 2.7
*/
@Deprecated
- public static <KEY, VALUE> Map<KEY, VALUE> parse(String data, Transformer<KEY, VALUE> transformer) {
+ public static <K, V> Map<K, V> parse(String data, Transformer<K, V> transformer) {
Map<String, String> rawData = parse(data);
- Map<KEY, VALUE> map = new HashMap<KEY, VALUE>();
+ Map<K, V> map = new HashMap<K, V>();
for (Map.Entry<String, String> entry : rawData.entrySet()) {
- KeyValue<KEY, VALUE> keyVal = transformer.transform(entry.getKey(), entry.getValue());
+ KeyValue<K, V> keyVal = transformer.transform(entry.getKey(), entry.getValue());
if (keyVal != null) {
map.put(keyVal.getKey(), keyVal.getValue());
}
externalCodeVisitors.add(pico.getComponent(visitor));
}
- public <SCANNER extends CodeScanner> SCANNER register(Class<SCANNER> scannerClass) {
+ public <S extends CodeScanner> S register(Class<S> scannerClass) {
if(pico.getComponent(scannerClass) != null){
throw new IllegalStateException("The Squid SCANNER '" + scannerClass.getName() + "' can't be registered multiple times.");
}
addToPicocontainer(scannerClass);
- SCANNER scanner = pico.getComponent(scannerClass);
+ S scanner = pico.getComponent(scannerClass);
for (Object clazz : scanner.getVisitorClasses()) {
addToPicocontainer((Class) clazz);
scanner.accept(pico.<CodeVisitor> getComponent((Class) clazz));
import java.util.Collection;
import java.util.List;
-public abstract class CodeScanner<VISITOR extends CodeVisitor> {
+public abstract class CodeScanner<V extends CodeVisitor> {
private List<CodeVisitor> visitors = new ArrayList<CodeVisitor>();
- public abstract Collection<Class<? extends VISITOR>> getVisitorClasses();
+ public abstract Collection<Class<? extends V>> getVisitorClasses();
public void accept(CodeVisitor visitor) {
visitors.add(visitor);
}
- public List<VISITOR> getVisitors() {
- return (List<VISITOR>) visitors;
+ public List<V> getVisitors() {
+ return (List<V>) visitors;
}
}
return this;
}
- public <SOURCECODE extends SourceCode> SOURCECODE getParent(Class<SOURCECODE> sourceCode) {
+ public <S extends SourceCode> S getParent(Class<S> sourceCode) {
if (parent == null) {
return null;
}
if (parent.getClass().equals(sourceCode)) {
- return (SOURCECODE) parent;
+ return (S) parent;
}
return parent.getParent(sourceCode);
}
- public <SOURCECODE extends SourceCode> SOURCECODE getAncestor(Class<SOURCECODE> withClass) {
- SOURCECODE ancestor = getParent(withClass);
+ public <S extends SourceCode> S getAncestor(Class<S> withClass) {
+ S ancestor = getParent(withClass);
if (ancestor!=null) {
- SOURCECODE parentAncestor = ancestor.getAncestor(withClass);
+ S parentAncestor = ancestor.getAncestor(withClass);
if (parentAncestor!=null) {
ancestor = parentAncestor;
}
private ChannelMatchers() {
}
- public static <OUTPUT> ChannelMatcher<OUTPUT> consume(String sourceCode, OUTPUT output) {
- return new ChannelMatcher<OUTPUT>(sourceCode, output);
+ public static <O> ChannelMatcher<O> consume(String sourceCode, O output) {
+ return new ChannelMatcher<O>(sourceCode, output);
}
- public static <OUTPUT> ChannelMatcher<OUTPUT> consume(CodeReader codeReader, OUTPUT output) {
- return new ChannelMatcher<OUTPUT>(codeReader, output);
+ public static <O> ChannelMatcher<O> consume(CodeReader codeReader, O output) {
+ return new ChannelMatcher<O>(codeReader, output);
}
public static ReaderHasNextCharMatcher hasNextChar(char nextChar) {
return connector;
}
- public <MODEL extends Model> MODEL find(Query<MODEL> query) {
+ public <M extends Model> M find(Query<M> query) {
String json = connector.execute(query);
- MODEL result = null;
+ M result = null;
if (json != null) {
try {
- Unmarshaller<MODEL> unmarshaller = Unmarshallers.forModel(query.getModelClass());
+ Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass());
result = unmarshaller.toModel(json);
} catch (Exception e) {
throw new UnmarshalException(query, json, e);
return result;
}
- public <MODEL extends Model> List<MODEL> findAll(Query<MODEL> query) {
+ public <M extends Model> List<M> findAll(Query<M> query) {
String json = connector.execute(query);
- List<MODEL> result;
+ List<M> result;
if (json == null) {
result = Collections.emptyList();
} else {
try {
- Unmarshaller<MODEL> unmarshaller = Unmarshallers.forModel(query.getModelClass());
+ Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass());
result = unmarshaller.toModels(json);
} catch (Exception e) {
throw new UnmarshalException(query, json, e);
return result;
}
- public <MODEL extends Model> MODEL create(CreateQuery<MODEL> query) {
+ public <M extends Model> M create(CreateQuery<M> query) {
String json = connector.execute(query);
- MODEL result = null;
+ M result = null;
if (json != null) {
try {
- Unmarshaller<MODEL> unmarshaller = Unmarshallers.forModel(query.getModelClass());
+ Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass());
result = unmarshaller.toModel(json);
} catch (Exception e) {
throw new UnmarshalException(query, json, e);
/**
* @since 2.2
*/
-public abstract class AbstractQuery<MODEL extends Model> {
+public abstract class AbstractQuery<M extends Model> {
/**
* Default timeout for waiting data, in milliseconds.
*
* @since 2.10
*/
- public final AbstractQuery<MODEL> setTimeoutMilliseconds(int i) {
+ public final AbstractQuery<M> setTimeoutMilliseconds(int i) {
this.timeoutMilliseconds = (i < 0 ? 0 : i);
return this;
}
*
* @since 2.10
*/
- public final AbstractQuery<MODEL> setLocale(String locale) {
+ public final AbstractQuery<M> setLocale(String locale) {
this.locale = locale;
return this;
}
*
* @since 2.2
*/
-public abstract class CreateQuery<MODEL extends Model> extends AbstractQuery<MODEL> {
+public abstract class CreateQuery<M extends Model> extends AbstractQuery<M> {
- public abstract Class<MODEL> getModelClass();
+ public abstract Class<M> getModelClass();
}
/**
* @since 2.1
*/
-public abstract class Query<MODEL extends Model> extends AbstractQuery<MODEL> {
+public abstract class Query<M extends Model> extends AbstractQuery<M> {
- public abstract Class<MODEL> getModelClass();
+ public abstract Class<M> getModelClass();
}
\ No newline at end of file
*
* @since 2.6
*/
-public abstract class UpdateQuery<MODEL extends Model> extends AbstractQuery<MODEL> {
+public abstract class UpdateQuery<M extends Model> extends AbstractQuery<M> {
- public abstract Class<MODEL> getModelClass();
+ public abstract Class<M> getModelClass();
}
import java.util.ArrayList;
import java.util.List;
-public abstract class AbstractUnmarshaller<MODEL extends Model> implements Unmarshaller<MODEL> {
+public abstract class AbstractUnmarshaller<M extends Model> implements Unmarshaller<M> {
- public final MODEL toModel(String json) {
+ public final M toModel(String json) {
WSUtils utils = WSUtils.getINSTANCE();
- MODEL result = null;
+ M result = null;
Object array = utils.parse(json);
if (utils.getArraySize(array) >= 1) {
Object elt = utils.getArrayElement(array, 0);
}
- public final List<MODEL> toModels(String json) {
+ public final List<M> toModels(String json) {
WSUtils utils = WSUtils.getINSTANCE();
- List<MODEL> result = new ArrayList<MODEL>();
+ List<M> result = new ArrayList<M>();
Object array = utils.parse(json);
for (int i = 0; i < utils.getArraySize(array); i++) {
Object elt = utils.getArrayElement(array, i);
return result;
}
- protected abstract MODEL parse(Object elt);
+ protected abstract M parse(Object elt);
}
unmarshallers.put(Authentication.class, new AuthenticationUnmarshaller());
}
- public static <MODEL extends Model> Unmarshaller<MODEL> forModel(Class<MODEL> modelClass) {
+ public static <M extends Model> Unmarshaller<M> forModel(Class<M> modelClass) {
return unmarshallers.get(modelClass);
}
}