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

com.github.dreamhead.moco.resource.Resource Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco.resource;

import com.github.dreamhead.moco.ConfigApplier;
import com.github.dreamhead.moco.MocoConfig;
import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.model.MessageContent;
import com.google.common.base.Optional;

public class Resource implements Identifiable, ConfigApplier, ResourceReader {
    private final Identifiable identifiable;
    private final ResourceConfigApplier configApplier;
    private final ResourceReader reader;

    public Resource(final Identifiable identifiable,
                    final ResourceConfigApplier configApplier,
                    final ResourceReader reader) {
        this.identifiable = identifiable;
        this.configApplier = configApplier;
        this.reader = reader;
    }

    @Override
    public Resource apply(final MocoConfig config) {
        return configApplier.apply(config, this);
    }

    @Override
    public String id() {
        return identifiable.id();
    }

    @Override
    public MessageContent readFor(final Optional request) {
        return reader.readFor(request);
    }

    public  T reader(final Class clazz) {
        return clazz.cast(reader);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy