org.opendaylight.cardinal.impl.MOScalarFactory Maven / Gradle / Ivy
The newest version!
/*
* Copyright © 2015 TCS and others. 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
*/
package org.opendaylight.cardinal.impl;
import org.snmp4j.agent.mo.MOAccessImpl;
import org.snmp4j.agent.mo.MOScalar;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
/**
*
* @author Subodh Roy
*
*/
public class MOScalarFactory {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static MOScalar createReadOnly(OID oid, Object value) {
return new MOScalar(oid, MOAccessImpl.ACCESS_READ_ONLY, getVariable(value));
}
private static Variable getVariable(Object value) {
if (value instanceof String) {
return new OctetString((String) value);
}
throw new IllegalArgumentException("Unmanaged Type: " + value.getClass());
}
}