DataExternalizer<Usage> (final DependencyContext context) { return new DataExternalizer<Usage>() { @Override public void save(final @NotNull DataOutput out, final Usage value) { value.save(out); } @Override public Usage read(@NotNull DataInput in) throws IOException { final byte tag = in.readByte(); switch (tag) { case CLASS_USAGE: return context.getUsage(new ClassUsage(in)); case CLASS_AS_GENERIC_BOUND_USAGE: return context.getUsage(new ClassAsGenericBoundUsage(in)); case CLASS_EXTENDS_USAGE: return context.getUsage(new ClassExtendsUsage(in)); case CLASS_NEW_USAGE: return context.getUsage(new ClassNewUsage(in)); case FIELD_USAGE: return context.getUsage(new FieldUsage(context, in)); case FIELD_ASSIGN_USAGE: return context.getUsage(new FieldAssignUsage(context, in)); case METHOD_USAGE: return context.getUsage(new MethodUsage(context, in)); case ANNOTATION_USAGE: return context.getUsage(new AnnotationUsage(context, in)); case METAMETHOD_USAGE: return context.getUsage(new MetaMethodUsage(in)); case MODULE_USAGE: return context.getUsage(new ModuleUsage(in)); case IMPORT_STATIC_MEMBER_USAGE: return context.getUsage(new ImportStaticMemberUsage(in)); case IMPORT_STATIC_ON_DEMAND_USAGE: return context.getUsage(new ImportStaticOnDemandUsage(in)); default: throw new IOException("Unknown usage with tag " + tag); } } }; }