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

org.esbtools.lightbluenotificationhook.NotificationHookConfigurationParser Maven / Gradle / Ivy

There is a newer version: 0.1.9
Show newest version
package org.esbtools.lightbluenotificationhook;

import com.redhat.lightblue.hooks.CRUDHook;
import com.redhat.lightblue.metadata.HookConfiguration;
import com.redhat.lightblue.metadata.parser.HookConfigurationParser;
import com.redhat.lightblue.metadata.parser.MetadataParser;

/**
 * Entry-point for lightblue to the hook.
 */
public class NotificationHookConfigurationParser implements HookConfigurationParser {
    @Override
    public String getName() {
        return "notificationHook";
    }

    @Override
    public CRUDHook getCRUDHook() {
        return new NotificationHook(getName());
    }

    @Override
    public NotificationHookConfiguration parse(String name, MetadataParser parser, T parseMe) {
        return NotificationHookConfiguration.fromMetadata(parser, parseMe);
    }

    @Override
    public void convert(MetadataParser parser, T writeMe, HookConfiguration hookConfiguration) {
        if (hookConfiguration == null) {
            hookConfiguration = NotificationHookConfiguration.watchingEverythingAndIncludingNothing();
        } else if (!(hookConfiguration instanceof NotificationHookConfiguration)) {
            throw new IllegalArgumentException("Can only parse NotificationHookConfiguration but " +
                    "got: " + hookConfiguration);
        }

        NotificationHookConfiguration config = (NotificationHookConfiguration) hookConfiguration;

        config.toMetadata(parser, writeMe);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy