Skip to content
Snippets Groups Projects
Commit 502b0553 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

fixed generics

parent 979ee655
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,7 @@ public class MarkerService implements IMarkerService,
/** {@inheritDoc} */
@Override
public Collection<IConstraintViolation<EObject>> getViolations(
public Collection<IConstraintViolation<? extends EObject>> getViolations(
EObject element) {
ITopLevelElement top = IPersistencyService.INSTANCE
.getTopLevelElementFor(element);
......@@ -163,7 +163,7 @@ public class MarkerService implements IMarkerService,
@Override
public void refreshMarkers(ITopLevelElement element) {
List<IConstraintViolation<EObject>> checkResult = IConstraintCheckerService.INSTANCE
List<IConstraintViolation<? extends EObject>> checkResult = IConstraintCheckerService.INSTANCE
.performAllConstraintChecksRecursively(element
.getTopLevelElement());
synchronized (violationCache) {
......@@ -262,7 +262,7 @@ public class MarkerService implements IMarkerService,
private static class CacheEntry {
/** Stores the mapping from model elements to violation lists. */
private final Map<EObject, List<IConstraintViolation<EObject>>> violationsMap = new HashMap<EObject, List<IConstraintViolation<EObject>>>();
private final Map<EObject, List<IConstraintViolation<? extends EObject>>> violationsMap = new HashMap<EObject, List<IConstraintViolation<? extends EObject>>>();
/** Stores the highest severity value for each cached element. */
private final Map<EObject, ESeverity> highestSeverityMap = new HashMap<EObject, ESeverity>();
......@@ -286,15 +286,15 @@ public class MarkerService implements IMarkerService,
/** Updates the cache entry. */
public synchronized void updateCacheEntries(
List<IConstraintViolation<EObject>> newViolations) {
List<IConstraintViolation<? extends EObject>> newViolations) {
clearCachedLists();
// update cache entries
for (IConstraintViolation<EObject> violation : newViolations) {
for (IConstraintViolation<? extends EObject> violation : newViolations) {
getCachedList(violation.getSource()).add(violation);
}
// fix cached list order
for (EObject eo : violationsMap.keySet()) {
List<IConstraintViolation<EObject>> list = violationsMap
List<IConstraintViolation<? extends EObject>> list = violationsMap
.get(eo);
if (list.isEmpty()) {
highestSeverityMap.put(eo, ESeverity.lowest());
......@@ -325,12 +325,12 @@ public class MarkerService implements IMarkerService,
/**
* Returns the cached list instance creating it if necessary.
*/
private List<IConstraintViolation<EObject>> getCachedList(
private List<IConstraintViolation<? extends EObject>> getCachedList(
EObject element) {
List<IConstraintViolation<EObject>> list = violationsMap
List<IConstraintViolation<? extends EObject>> list = violationsMap
.get(element);
if (list == null) {
list = new ArrayList<IConstraintViolation<EObject>>();
list = new ArrayList<IConstraintViolation<? extends EObject>>();
violationsMap.put(element, list);
}
return list;
......@@ -338,7 +338,7 @@ public class MarkerService implements IMarkerService,
/** Clears all cached lists. */
private void clearCachedLists() {
for (List<IConstraintViolation<EObject>> list : violationsMap
for (List<IConstraintViolation<? extends EObject>> list : violationsMap
.values()) {
list.clear();
}
......
......@@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.ui.internal.MarkerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 30E5845252B4939B202D380028CBB6B1
* @ConQAT.Rating GREEN Hash: 579B2321FC685A2D551FAFF13A0FB3A6
*/
public interface IMarkerService {
......@@ -42,7 +42,8 @@ public interface IMarkerService {
public static final IMarkerService INSTANCE = new MarkerService();
/** Returns the constraint violations for the given element. */
Collection<IConstraintViolation<EObject>> getViolations(EObject element);
Collection<IConstraintViolation<? extends EObject>> getViolations(
EObject element);
/** Returns the highest severity for the given element. */
ESeverity getHighestViolationSeverity(EObject element);
......
......@@ -36,7 +36,7 @@ import org.fortiss.tooling.kernel.service.base.IEObjectAware;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9D1C13DDE03060268433FC560D3BB754
* @ConQAT.Rating GREEN Hash: 16D08BC35D459B4038A71F198B561B27
*/
public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C> {
......@@ -47,5 +47,5 @@ public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C>
boolean isApplicable(C modelElement);
/** Applies the constraint checker to the given model element. */
IConstraintViolation<EObject> apply(C modelElement);
IConstraintViolation<? extends EObject> apply(C modelElement);
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| 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.fortiss.tooling.kernel.extension.base;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
* Base implementation for model element constraint checkers.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3DDF9C3071E7CA9B599EFAFEEC27DDFF
*/
public abstract class ConstraintViolationBase<T extends EObject> implements
IConstraintViolation<T> {
/** Stores the model element. */
private final T source;
/** Constructor. */
public ConstraintViolationBase(T source) {
this.source = source;
}
/** {@inheritDoc} */
@Override
public T getSource() {
return source;
}
/** {@inheritDoc} */
@Override
public IQuickFixHandler getQuickFixHandler() {
return null;
}
}
......@@ -30,7 +30,7 @@ import org.eclipse.emf.ecore.EObject;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 59B63AA8B22AF7224E17B92B0CD261BF
* @ConQAT.Rating GREEN Hash: 6340788DB3948AD781A97861749504DB
*/
public interface IConstraintViolation<T extends EObject> {
......@@ -88,11 +88,11 @@ public interface IConstraintViolation<T extends EObject> {
}
/** Stores the severity comparator used during violation sorting. */
public static final Comparator<IConstraintViolation<EObject>> SEVERITY_COMPARATOR = new Comparator<IConstraintViolation<EObject>>() {
public static final Comparator<IConstraintViolation<? extends EObject>> SEVERITY_COMPARATOR = new Comparator<IConstraintViolation<? extends EObject>>() {
/** {@inheritDoc} */
@Override
public int compare(IConstraintViolation<EObject> arg0,
IConstraintViolation<EObject> arg1) {
public int compare(IConstraintViolation<? extends EObject> arg0,
IConstraintViolation<? extends EObject> arg1) {
int sev0 = ESeverity.getIntSeverity(arg0.getSeverity());
int sev1 = ESeverity.getIntSeverity(arg1.getSeverity());
return sev0 - sev1;
......
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
......@@ -34,7 +35,7 @@ import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: FEB4237E503A79A9B119E465A3D49C31
* @ConQAT.Rating GREEN Hash: 74C0500ED08841180F543A62284F2A9E
*/
public class ConstraintCheckerService extends
EObjectAwareServiceBase<IConstraintChecker<EObject>> implements
......@@ -51,9 +52,9 @@ public class ConstraintCheckerService extends
/** {@inheritDoc} */
@Override
public List<IConstraintViolation<EObject>> performAllConstraintChecksRecursively(
public List<IConstraintViolation<? extends EObject>> performAllConstraintChecksRecursively(
EObject modelElement) {
List<IConstraintViolation<EObject>> result = new LinkedList<IConstraintViolation<EObject>>();
List<IConstraintViolation<? extends EObject>> result = new LinkedList<IConstraintViolation<? extends EObject>>();
performConstraintCheck(modelElement, result);
for (Iterator<EObject> iter = modelElement.eAllContents(); iter
.hasNext();) {
......@@ -65,9 +66,9 @@ public class ConstraintCheckerService extends
/** {@inheritDoc} */
@Override
public List<IConstraintViolation<EObject>> performAllConstraintChecks(
public List<IConstraintViolation<? extends EObject>> performAllConstraintChecks(
EObject modelElement) {
List<IConstraintViolation<EObject>> result = new LinkedList<IConstraintViolation<EObject>>();
List<IConstraintViolation<? extends EObject>> result = new LinkedList<IConstraintViolation<? extends EObject>>();
performConstraintCheck(modelElement, result);
Collections.sort(result, IConstraintViolation.SEVERITY_COMPARATOR);
return result;
......@@ -79,7 +80,7 @@ public class ConstraintCheckerService extends
* considered.
*/
private void performConstraintCheck(EObject modelElement,
List<IConstraintViolation<EObject>> violationList) {
List<IConstraintViolation<? extends EObject>> violationList) {
List<IConstraintChecker<EObject>> handlers = getRegisteredHandlers(modelElement
.getClass());
if (handlers == null) {
......@@ -87,7 +88,7 @@ public class ConstraintCheckerService extends
}
for (IConstraintChecker<EObject> checker : handlers) {
if (checker.isApplicable(modelElement)) {
IConstraintViolation<EObject> violation = checker
IConstraintViolation<? extends EObject> violation = checker
.apply(modelElement);
if (violation != null) {
violationList.add(violation);
......@@ -98,9 +99,10 @@ public class ConstraintCheckerService extends
/** {@inheritDoc} */
@Override
public List<IConstraintChecker<EObject>> getAllConstraintCheckers(
public List<IConstraintChecker<? extends EObject>> getAllConstraintCheckers(
EObject modelElement) {
return getRegisteredHandlers(modelElement.getClass());
return new ArrayList<IConstraintChecker<? extends EObject>>(
getRegisteredHandlers(modelElement.getClass()));
}
/** {@inheritDoc} */
......
......@@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.internal.ConstraintCheckerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9F13D22CC269B9811CD13C341024AA78
* @ConQAT.Rating GREEN Hash: C0BC2D1C3BDE3F2ECEA8E91A612857EF
*/
public interface IConstraintCheckerService {
......@@ -49,7 +49,7 @@ public interface IConstraintCheckerService {
* The returned list is ordered according to {@link ESeverity} from FATAL to
* DEBUG.
*/
List<IConstraintViolation<EObject>> performAllConstraintChecksRecursively(
List<IConstraintViolation<? extends EObject>> performAllConstraintChecksRecursively(
EObject modelElement);
/**
......@@ -59,13 +59,13 @@ public interface IConstraintCheckerService {
* The returned list is ordered according to {@link ESeverity} from FATAL to
* DEBUG.
*/
<T extends EObject> List<IConstraintViolation<T>> performAllConstraintChecks(
T modelElement);
List<IConstraintViolation<? extends EObject>> performAllConstraintChecks(
EObject modelElement);
/**
* Returns the list of registered constraint checkers for the given model
* element.
*/
<T extends EObject> List<IConstraintChecker<T>> getAllConstraintCheckers(
T modelElement);
List<IConstraintChecker<? extends EObject>> getAllConstraintCheckers(
EObject modelElement);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment