blob: 77bfc8a6aa82739750cfcd9aa34be809f2c8ee04 [file] [log] [blame]
/*
* Copyright (c) 2011 Google Inc.
*
* 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 com.google.eclipse.protobuf.model.util;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.inject.Singleton;
/**
* Utility methods related to fields in <code>{@link Option}</code>s
*
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton
public class OptionFields {
/**
* Returns the field the given option field is referring to.
* @param field the given option field.
* @return the field the given option field is referring to, or {@code null} if one cannot be found.
*/
public IndexedElement sourceOf(OptionField field) {
if (field instanceof MessageOptionField) {
return ((MessageOptionField) field).getTarget();
}
if (field instanceof ExtensionOptionField) {
return ((ExtensionOptionField) field).getTarget();
}
return null;
}
}