X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.message%2Fsrc%2Forg%2Fsimantics%2Fmessage%2FAbstractMessageSchemeHandler.java;h=0e9c5d54f77de35e34585e21e3233b289c9da609;hb=d47f93197f84f8e5afd2bd9e1f12984be0e1ff8c;hp=53dc4e96d438aa7f597ae91df45bb025bc93a4e8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.message/src/org/simantics/message/AbstractMessageSchemeHandler.java b/bundles/org.simantics.message/src/org/simantics/message/AbstractMessageSchemeHandler.java index 53dc4e96d..0e9c5d54f 100644 --- a/bundles/org.simantics.message/src/org/simantics/message/AbstractMessageSchemeHandler.java +++ b/bundles/org.simantics.message/src/org/simantics/message/AbstractMessageSchemeHandler.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.message; - - -/** - * Example usage: - *
- * public class MyResourceSchemeHandler extends AbstractMessageSchemeHandler {
- *     public MyResourceSchemeHandler() {
- *         super("myresource", MyResource.class);
- *     }
- *     public void doPerform(MyResource r) {
- *         // Do your stuff...
- *     }
- * }
- * 
- * - * @author Tuukka Lehtonen - */ -public abstract class AbstractMessageSchemeHandler implements IMessageSchemeHandler { - - private String scheme; - private Class expectedDataClass; - - public AbstractMessageSchemeHandler(String scheme, Class expectedDataClass) { - this.scheme = scheme; - this.expectedDataClass = expectedDataClass; - } - - @Override - public String getScheme() { - return scheme; - } - - @SuppressWarnings("unchecked") - @Override - public void perform(Object o) throws MessageSchemeException { - if (expectedDataClass.isInstance(o)) { - doPerform((T) o); - } else { - handleInvalidData(o); - } - } - - public void handleInvalidData(Object o) { - // Override to handle differently - throw new RuntimeException("Object " + o + " is not an instance of " + expectedDataClass.getCanonicalName()); - } - - public abstract void doPerform(T o) throws MessageSchemeException; - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.message; + + +/** + * Example usage: + *
+ * public class MyResourceSchemeHandler extends AbstractMessageSchemeHandler {
+ *     public MyResourceSchemeHandler() {
+ *         super("myresource", MyResource.class);
+ *     }
+ *     public void doPerform(MyResource r) {
+ *         // Do your stuff...
+ *     }
+ * }
+ * 
+ * + * @author Tuukka Lehtonen + */ +public abstract class AbstractMessageSchemeHandler implements IMessageSchemeHandler { + + private String scheme; + private Class expectedDataClass; + + public AbstractMessageSchemeHandler(String scheme, Class expectedDataClass) { + this.scheme = scheme; + this.expectedDataClass = expectedDataClass; + } + + @Override + public String getScheme() { + return scheme; + } + + @SuppressWarnings("unchecked") + @Override + public void perform(Object o) throws MessageSchemeException { + if (expectedDataClass.isInstance(o)) { + doPerform((T) o); + } else { + handleInvalidData(o); + } + } + + public void handleInvalidData(Object o) { + // Override to handle differently + throw new RuntimeException("Object " + o + " is not an instance of " + expectedDataClass.getCanonicalName()); + } + + public abstract void doPerform(T o) throws MessageSchemeException; + +}