use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project mechanoid by robotoworks.
the class ActiveRecordGenerator method _generateSetFromCursorStatements.
protected CharSequence _generateSetFromCursorStatements(final CreateTableStatement stmt) {
StringConcatenation _builder = new StringConcatenation();
{
EList<ColumnSource> _columnDefs = stmt.getColumnDefs();
final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {
public Boolean apply(final ColumnSource it) {
String _name = it.getName();
boolean _equals = _name.equals("_id");
return Boolean.valueOf((!_equals));
}
};
Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(_columnDefs, _function);
for (final ColumnSource item : _filter) {
ColumnDef col = ((ColumnDef) item);
_builder.newLineIfNotEmpty();
{
ColumnType _type = col.getType();
boolean _equals = Objects.equal(_type, ColumnType.BOOLEAN);
if (_equals) {
_builder.append("set");
String _name = col.getName();
String _pascalize = Strings.pascalize(_name);
_builder.append(_pascalize, "");
_builder.append("(c.getInt(Indices.");
String _name_1 = col.getName();
String _underscore = Strings.underscore(_name_1);
String _upperCase = _underscore.toUpperCase();
_builder.append(_upperCase, "");
_builder.append(") > 0);");
_builder.newLineIfNotEmpty();
} else {
ColumnType _type_1 = col.getType();
boolean _equals_1 = Objects.equal(_type_1, ColumnType.BLOB);
if (_equals_1) {
_builder.append("set");
String _name_2 = col.getName();
String _pascalize_1 = Strings.pascalize(_name_2);
_builder.append(_pascalize_1, "");
_builder.append("(c.getBlob(Indices.");
String _name_3 = col.getName();
String _underscore_1 = Strings.underscore(_name_3);
String _upperCase_1 = _underscore_1.toUpperCase();
_builder.append(_upperCase_1, "");
_builder.append("));");
_builder.newLineIfNotEmpty();
} else {
_builder.append("set");
String _name_4 = col.getName();
String _pascalize_2 = Strings.pascalize(_name_4);
_builder.append(_pascalize_2, "");
_builder.append("(c.get");
ColumnType _type_2 = col.getType();
String _javaTypeName = ModelUtil.toJavaTypeName(_type_2);
String _pascalize_3 = Strings.pascalize(_javaTypeName);
_builder.append(_pascalize_3, "");
_builder.append("(Indices.");
String _name_5 = col.getName();
String _underscore_2 = Strings.underscore(_name_5);
String _upperCase_2 = _underscore_2.toUpperCase();
_builder.append(_upperCase_2, "");
_builder.append("));");
_builder.newLineIfNotEmpty();
}
}
}
}
}
return _builder;
}
use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project mechanoid by robotoworks.
the class ActiveRecordGenerator method _generateParcelDeserializationStatements.
protected CharSequence _generateParcelDeserializationStatements(final CreateTableStatement stmt) {
StringConcatenation _builder = new StringConcatenation();
int counter = (-1);
_builder.newLineIfNotEmpty();
{
EList<ColumnSource> _columnDefs = stmt.getColumnDefs();
final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {
public Boolean apply(final ColumnSource it) {
String _name = it.getName();
boolean _equals = _name.equals("_id");
return Boolean.valueOf((!_equals));
}
};
Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(_columnDefs, _function);
for (final ColumnSource item : _filter) {
ColumnDef col = ((ColumnDef) item);
_builder.newLineIfNotEmpty();
{
ColumnType _type = col.getType();
boolean _equals = Objects.equal(_type, ColumnType.BOOLEAN);
if (_equals) {
_builder.append("m");
String _name = col.getName();
String _pascalize = Strings.pascalize(_name);
_builder.append(_pascalize, "");
_builder.append(" = (in.readInt() > 0);");
_builder.newLineIfNotEmpty();
} else {
ColumnType _type_1 = col.getType();
boolean _equals_1 = Objects.equal(_type_1, ColumnType.BLOB);
if (_equals_1) {
_builder.append("m");
String _name_1 = col.getName();
String _pascalize_1 = Strings.pascalize(_name_1);
_builder.append(_pascalize_1, "");
_builder.append(" = in.createByteArray();");
_builder.newLineIfNotEmpty();
} else {
_builder.append("m");
String _name_2 = col.getName();
String _pascalize_2 = Strings.pascalize(_name_2);
_builder.append(_pascalize_2, "");
_builder.append(" = in.read");
ColumnType _type_2 = col.getType();
String _javaTypeName = ModelUtil.toJavaTypeName(_type_2);
String _pascalize_3 = Strings.pascalize(_javaTypeName);
_builder.append(_pascalize_3, "");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
}
}
}
}
_builder.newLine();
_builder.append("boolean[] dirtyFlags = new boolean[");
EList<ColumnSource> _columnDefs_1 = stmt.getColumnDefs();
int _size = _columnDefs_1.size();
int _minus = (_size - 1);
_builder.append(_minus, "");
_builder.append("];");
_builder.newLineIfNotEmpty();
_builder.append("in.readBooleanArray(dirtyFlags);");
_builder.newLine();
{
EList<ColumnSource> _columnDefs_2 = stmt.getColumnDefs();
final Function1<ColumnSource, Boolean> _function_1 = new Function1<ColumnSource, Boolean>() {
public Boolean apply(final ColumnSource it) {
String _name = it.getName();
boolean _equals = _name.equals("_id");
return Boolean.valueOf((!_equals));
}
};
Iterable<ColumnSource> _filter_1 = IterableExtensions.<ColumnSource>filter(_columnDefs_2, _function_1);
for (final ColumnSource col_1 : _filter_1) {
_builder.append("m");
String _name_3 = col_1.getName();
String _pascalize_4 = Strings.pascalize(_name_3);
_builder.append(_pascalize_4, "");
_builder.append("Dirty = dirtyFlags[");
_builder.append(counter = (counter + 1), "");
_builder.append("];");
_builder.newLineIfNotEmpty();
}
}
return _builder;
}
use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project mechanoid by robotoworks.
the class ActiveRecordGenerator method _generateMakeDirtyStatements.
protected CharSequence _generateMakeDirtyStatements(final CreateViewStatement stmt) {
StringConcatenation _builder = new StringConcatenation();
ArrayList<ColumnSource> cols = ModelUtil.getViewResultColumns(stmt);
_builder.newLineIfNotEmpty();
{
final Function1<ColumnSource, Boolean> _function = new Function1<ColumnSource, Boolean>() {
public Boolean apply(final ColumnSource it) {
String _name = it.getName();
boolean _equals = _name.equals("_id");
return Boolean.valueOf((!_equals));
}
};
Iterable<ColumnSource> _filter = IterableExtensions.<ColumnSource>filter(cols, _function);
for (final ColumnSource col : _filter) {
_builder.append("m");
String _name = col.getName();
String _pascalize = Strings.pascalize(_name);
_builder.append(_pascalize, "");
_builder.append("Dirty = dirty;");
_builder.newLineIfNotEmpty();
}
}
return _builder;
}
use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project mechanoid by robotoworks.
the class ContentProviderContractGenerator method generateContractItemsForActions.
public CharSequence generateContractItemsForActions(final Model model, final SqliteDatabaseSnapshot snapshot) {
StringConcatenation _builder = new StringConcatenation();
{
DatabaseBlock _database = model.getDatabase();
ConfigBlock _config = _database.getConfig();
boolean _notEquals = (!Objects.equal(_config, null));
if (_notEquals) {
{
DatabaseBlock _database_1 = model.getDatabase();
ConfigBlock _config_1 = _database_1.getConfig();
EList<ConfigurationStatement> _statements = _config_1.getStatements();
Iterable<ActionStatement> _filter = Iterables.<ActionStatement>filter(_statements, ActionStatement.class);
final Function1<ActionStatement, Boolean> _function = new Function1<ActionStatement, Boolean>() {
public Boolean apply(final ActionStatement it) {
ContentUri _uri = it.getUri();
String _type = _uri.getType();
boolean _containsDefinition = snapshot.containsDefinition(_type);
return Boolean.valueOf((!_containsDefinition));
}
};
Iterable<ActionStatement> _filter_1 = IterableExtensions.<ActionStatement>filter(_filter, _function);
for (final ActionStatement action : _filter_1) {
_builder.append("public static class ");
ContentUri _uri = action.getUri();
String _type = _uri.getType();
String _pascalize = Strings.pascalize(_type);
_builder.append(_pascalize, "");
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _createActionUriBuilderMethod = this.createActionUriBuilderMethod(action);
_builder.append(_createActionUriBuilderMethod, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public static final String CONTENT_TYPE =");
_builder.newLine();
_builder.append("\t ");
_builder.append("\"vnd.android.cursor.dir/vnd.");
DatabaseBlock _database_2 = model.getDatabase();
String _name = _database_2.getName();
String _lowerCase = _name.toLowerCase();
_builder.append(_lowerCase, "\t ");
_builder.append(".");
ContentUri _uri_1 = action.getUri();
String _type_1 = _uri_1.getType();
_builder.append(_type_1, "\t ");
_builder.append("\";");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_builder.newLine();
}
}
}
}
return _builder;
}
use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project mechanoid by robotoworks.
the class ModelUtil method isDefinitionReferencedByView.
public static boolean isDefinitionReferencedByView(final TableDefinition tableDef, final CreateViewStatement view) {
TreeIterator<EObject> _eAllContents = view.eAllContents();
final Function1<EObject, Boolean> _function = new Function1<EObject, Boolean>() {
public Boolean apply(final EObject obj) {
if ((obj instanceof SingleSourceTable)) {
SingleSourceTable sourceTable = ((SingleSourceTable) obj);
TableDefinition _tableReference = sourceTable.getTableReference();
if ((!(_tableReference instanceof CreateViewStatement))) {
TableDefinition _tableReference_1 = sourceTable.getTableReference();
String _name = _tableReference_1.getName();
String _name_1 = tableDef.getName();
boolean _equals = _name.equals(_name_1);
if (_equals) {
return Boolean.valueOf(true);
}
} else {
TableDefinition _tableReference_2 = sourceTable.getTableReference();
return Boolean.valueOf(ModelUtil.isDefinitionReferencedByView(tableDef, ((CreateViewStatement) _tableReference_2)));
}
}
return Boolean.valueOf(false);
}
};
return IteratorExtensions.<EObject>exists(_eAllContents, _function);
}
Aggregations